interface

Achieving Interface functionality in C++

A big reason why I use OOP is to create code that is easily reusable. For that purpose Java style interfaces are perfect. However, when dealing with C++ I really can't achieve any sort of functionality like interfaces... at least not with ease. I know about pure virtual base classes, but what really ticks me off is that they force me in...

Organizing interfaces

I am just reading Agile Principles, Patterns and Practices in C# by R. Martin and M. Martin and they suggest in their book, to keep all your interfaces in a separate project, eg. Interfaces. As an example, if I have a Gui project, that contains all my custom Gui classes, I will keep their interfaces in the Interfaces project. Specifica...

How to best test Java code?

I have been working on a comparatively large system on my own, and it's my first time working on a large system(dealing with 200+ channels of information simultaneously). I know how to use Junit to test every method, and how to test boundary conditions. But still, for system test, I need to test all the interfacing and probably so some s...

Is there a way with Java Generics to take Generic parameter that requires implementation of 2 interfaces?

Say I have this code - public interface ParentInterface1 { public List<? extends ChildInterface1> getChildren(); public void setChildren(List<? extends ChildInterface1> children); } public interface ParentInterface2 { public List<? extends ChildInterface2> getChildren(); public void setChildren(List<? extends ChildInter...

How to load web user controls with interface type

I have a web user control which call some methods of an interface. Four different classes use this interface. public interface IMultiTextProvider { bool Insert(string text, Guid campaignId); IEnumerable<IMultiTextItem> GetItems(Guid campaignId); } In init or load I am setting up the controls like this (where wuc* is a control...

How to register generic interfaces in StructureMap...

How do I register all the instances of a generic interface in Structured Map? I know how to do this for a none generic interface: internal class MVCDemoRegistry : Registry { public MVCDemoRegistry() { Scan(x => { x.Assembly("MVCDemo"); x.Assembly("MVCDemo.Infra...

Factory Creating Objects According to a Generic Type C#

What would be the most efficient way to instanciate an object according to a generic type passed to a Factory class, for instance: public class LoggerFactory { public static ILogger<T> Create<T>() { // Switch Statement? // Generic Dictionary? // EX.: if "T" is of type "string": return (ILogger<T>)new Stri...

XML Object Deserialization to Interface

I have two classes SccmAction and TicketAction which both implement interface IDelivery. These classes will be transmitted on a processing queue from which I just want to pull the message and act upon the Deliver method. It seems however that I cannot deserialize to an interface because when I attempt to do so a System.NotSupportedExcep...

Common Interface for CouchDB and Amazon S3

I just read tons of material on Amazon's S3 and CouchDB. Maybe not enough yet though, so here is my question: Both systems sound very appealing to me. CouchDB is distributed using the Apache License V2 and with Amazon's S3, you pay per stored megabyte and the traffic you generate. So there is a bit of a difference monetarily. But from...

DLL library interface

Hi All, I have a question that bothers me for a long time. I have a mathematical library, implemented as DLL. The library implements many types of mathematical functions. The mathematical functions are implemented in different classes based on their functionality. For example, all functions that implements polynomial equations are unde...

does Inheritance really hide methods?

I am getting the following Compiler Warning: 'Resources.Foo.GetType()' hides inherited member 'object.GetType()'. Use the new keyword if hiding was intended. Resources.NET\Resources\Class1.cs 123 20 Resources for this (very simplified) code: public interface IFoo { int GetType(); string GetDisplayName(); } public class ...

Why InputStream and OutputStream implement Closeable and Socket doesn't?

Have seen this comment in a method: //I wonder why Sun made input and output streams implement Closeable and left Socket behind It would prevent creation of wrapper anonymous inner class which implements Closeable which delegates its close method to an instance of Socket. ...

Interfacing a slow device to a MCF5270 Microcontroller

Hi, I'm looking for ways to interface a slow device (an ADC - ~1.2MHz) to my mcf5270 microcontroller, which is a rather fast device (~150MHz). I am using ADC0817, and have tried the following: GPIO read off the data lines, memory mapped access (since the adc is uP compatible). When mapped as a location in memory, I am using the maximu...

JAXB Annotations - Mapping interfaces and @XmlElementWrapper

I am having trouble with JAXB annotations for a field that is a list whose generified type is an interface. When I have it declared such as: @XmlAnyElement private List<Animal> animals; Every thing works correctly. But when I add a wrapper element, such as: @XmlElementWrapper @XmlAnyElement private List<Animal> animals; I find tha...

Finding the Concrete Type behind an Interface instance

To cut a long story short I have a C# function that performs a task on a given Type that is passed in as an Object instance. All works fine when a class instance is passed in. However, when the object is declared as an interface I'd really like to find the concrete class and perform the action upon that class type. Here is the ubiquitou...

Implementing interface C#

I'm not new to C#, but I have found a behavior that is a little puzzling. I have an interface public interface IApplicationPage { Person ThePerson { get; set; } Application Application { get; set; } } I implement the interface on a page public partial class tripapplication2 : System.Web.UI.Page, IApplicationPage { Pe...

Check for implementation of an Interface recursively, c#

I have a situation in a WebForm where I need to recurse throguh the control tree to find all controls that implement a given interface. How would I do this? I have tried writing an extension method like this public static class ControlExtensions { public static List<T> FindControlsByInterface<T>(this Control control) { ...

How to create an interface with additional methods in F#

I'm trying to create an interface that requires additional methods on top of IEvent, like this: type Varying<'t> = abstract member Get : unit -> 't abstract member Set : 't -> unit abstract member AddHandler : Handler<'t> -> unit abstract member RemoveHandler : Handler<'t> -> unit member v.Add(f) = v.AddHandler(new ...

Why ArrayList implement IList, ICollection, IEnumerable?

ArrayList declare that it implements IList, ICollection, IEnumeralbe interfaces. Why not only implement IList, because IList is also derived from ICollection, ICollection is derived from IEnumerable. What's the purpose of this kind of declare? there are many cases like this in .net BCL. ...

Interface or abstract class?

For my new Pet-Project I have a question for design, that is decided already, but I want some other opinions on that too. I have a two classes (simplyfied): class MyObject { string name {get;set;} enum relation {get;set;} int value {get;set;} } class MyObjectGroup { string name {get;set;} enum relation {get;set;} int value...