interface

MEF: Loading parts (plug-ins) which have differing properties.

Brief Background: My team has decided to use Microsoft's Managed Extensibility Framework (MEF) in order to provide an extensible model for adding new "providers" into our system. This allows for us to plug in new 3rd party providers with relative ease. Note: I was impressed by how simple MEF was to use and get up and running with. My...

Java: How to avoid deprecated warning in derived interfaces which override deprecated members?

Consider the following simplified interface inheritence hierarchy: // Starting point: public interface Base { void Foo(); } public interface Derived extends Base { } It is intended to move the Foo method from the Base interface to the Derived interface: // Desired end-point: public interface Base { } public interface Derived ex...

Java interface and inheritance

If we have: public interface Foo{} public class Bar implements Foo{...} Is there a difference between: public class BarBar extends Bar implements Foo{..} and public class BarBar extends Bar{..} I see a lot of code like this and it always confuses me. Does BarBar need to implement Foo? I mean since it extends Bar to begin with i...

IList<IWhatever> as a method parameter

I have two IList<ICat> and I'm trying to create a method which takes an IList<ICat> and does some work. I'm having problems trying to pass either an IList<PussyCat> or IList<OtherCat> to it, both PussyCat and OtherCat implement ICat. I've tried: List<PussyCat> cats = ... DoWork((IList<ICat>)cats); and just DoWork(cats); But neithe...

Preferred way to simulate interfaces in C++

Since C++ lacks the interface feature of Java/C#, what is the preferred way to simulate interfaces in C++ classes? My guess would be multiple inheritance of abstract classes. What are the implications in terms of memory overhead/performance? Are there any naming conventions for such simulated interfaces, such as SerializableInterface? ...

Need help defining an Interface in C#

I have a data driven mapping application where I need to implement custom functions as plugins. The name of the custom method that I need to execute will also be in the mapping data. I know that I can call the method using the invoke command; but, how can I ensure that each method has the appropriate signature? ...

Only one parameterization of an interface can be implemented—how to work around?

Here's an example of what I'd like to be able to do (in Java): interface MyInterface<E> { public void doSomething(E foo); } class MyClass implements MyInterface<ClassA>, MyInterface<ClassB> { public void doSomething(ClassA fooA) { ... } public void doSomething(ClassB fooB) { ... } } When I try to implement this, th...

iPhone dev - Manually rotate view

How can I manually rotate a view using the autoresizingMasks, as if the user had rotated the phone and it had auto-rotated. Also I want it to be instant, no animation. I you want to know why I need this, look at my other question at http://stackoverflow.com/questions/1219988/iphone-dev-keeping-interface-rotation. Thanks!! ...

How can I pass a List<Interface> over WCF?

I have a WCF service where I am trying to return a List (where IWatchable is a custom interface I have built) in one of my operation contracts. When I test the service on the client the method returns an object[] instead of List<IWatchable>. Is it possible to return a List of IWatchable, since IWatchable is an interface with WCF? Method...

How do I implement members of internal interfaces

I have been refactoring the codebase of the project that I am currently on so that classes/interfaces which are not useful beyond the confines of the assembly should be declared as internal (rather than public). But I've run into a problem with the following code: internal interface IFirstInterface { ... } internal interface ISecon...

Abstract class and Interface class?

Hi, I'm new to Java. Why are abstract or interface classes created, or when should we use abstract or interface classes? ...

Throwing an Exception Not Defined in the Interface

What is the best practice to follow when you need to throw an exception which was not defined in an interface that you are implementing? Here is an example: public interface Reader { public abstract void read() throws IOException; } public class CarrotReader implements Reader { public void read() throws IOException {} } publi...

Indexer as part of the interface in C#

In C#, what's the syntax for declaring an indexer as part of an interface? Is it still this[ ]? Something feels odd about using the this keyword in an interface. ...

Method parameter can be a class or interface, little confused

Hi, If I have a class: public blah { } Then I have another class that inherits blah" public ablah : blah { } Can I do this then? public class Someservice { public bool SomeBlah(blah b) { } } Could I call it the service with either classes blah or ablah? ie. Someservice s1 = new Somesercie(); s1.SomeBlah(new blah());...

When to use interfaces or abstract classes? When to use both?

While certain guidelines state that you should use an interface when you want to define a contract for a class where inheritance is not clear (IDomesticated) and inheritance when the class is an extension of another (Cat : Mammal, Snake : Reptile), there are cases when (in my opinion) these guidelines enter a gray area. For example, say...

Unable to cast COM object of type exception

I have the following code: public void Test(IMyInterface iInterface) { iInterface.CallMethod ( ); } Which works fine. However, if I change the code to be threaded: private IMyInterface myInterface; public void Test(IMyInterface iInterface) { myInterface = iInterface; new Thread ( new ThreadStart ( CallInterfaceMethod) ).Start (...

Delphi: Since when are interface references no longer released at the end of a with-block?

I recently stumbled over a problem caused by some very old code I wrote which was obviously assuming that interface references used in a with statement would be released as soon as the with-block is left - kind of like an implicit try-finally-block (similar to C#'s using-statement if I understood correctly). Apparently (in Delphi 2009) ...

How to get the name of an interface at runtime?

If I have an object that implements an interface, it's not too difficult to use RTTI to look up the interface and obtain its GUID. But if I want its name, is there any way to get that? It's simple enough to get a class's name, but for interfaces it seems a bit trickier... ...

C#: How to implement IOrderedEnumerable<T>

I want to implement some various algorithms for practice, just to see how bad I really am and to get better :p Anyways, I thought I would try to use IEnumerable<T> and IOrderedEnumerable<T> and other .Net collection types just to be compatible (so that what I write can be used more easily later). But I can't find a way to return an ins...

Why can we cast a Java interface to *any* non-final class?

import java.util.Collection; public class Test { public static void main(String[] args) { Collection c = null; Test s = null; s = (Test) c; } } In the code sample above, I am casting a collection object to a Test object. (ignoring the null pointer). Test has no relationship to Collection whatsoeve...