interface

Java Interfaces?

I really need help with interfaces in general... Any resources that you guys would recommend me? Related: How are Java interfaces actually used? Java interface and inheritance Java Interface Usage Guidelines — Are getters and setters in an interface bad? Why can’t I define a static method in a Java interface? ...

WCF contract returning interface could cause serialization issue?

I am trying to define a WCF contract that returns an interface, something like below: [ServiceContract] public interface IMyContracts { [OperationContract] IMyInterface GetData(string request); } To get this to work I think my interface (IMyInterface) would have to implement ISerializable to ensure classes implementing my inte...

What aspects of a Web Browser should be configurable via plugins?

I'm looking at this from the perspective of the plugin developer not the user of the browser, so I'm interested in what developers think is the ideal interface for plugins to a browser. For example: Plugins can reorder, create and destroy Tabs, Plugins can draw behind and in front of Browser pages etc. I'm particularly concerned about...

Interfaces in Class Files

Should my interface and concrete implementation of that interface be broken out into two separate files? ...

Interfaces in Java: cannot make implemented methods protected or private

Hi all, I know that an interface must be public. However, I don't want that. I want my implemented methods to only be accessible from their own package, so I want my implemented methods to be protected. The problem is I can't make the interface or the implemented methods protected. What is a work around? Is there a design pattern...

Is this design a good idea - Interfaces and Abstract class

I would like to be able to do somthing like the following: //non-generic var MyTable = new Table(); string name = MyTable.Name; IEnumerable<String> rows = MyTable.Rows; //generic var MyTableGeneric = new Table<MyType>(); string name = MyTableGeneric.Name; IEnumerable<MyType> rows = MyTableGeneric .Rows; Would something like this be t...

Is referencing an implementing base type in an interface a code smell?

I'm faced with a design decision that doesn't smell to me, but gives me pause. Take a look at the following code sample: public interface IGenerator { ///<summary> /// Combines two generators; performs magic as well /// </summary> BaseGenerator Combine(BaseGenerator next); ///<summary> /// Does what a generator does. ///...

Do you accept interfaces as constructor parameters?

Does Krzysztof's recommendation apply to constructors? If so, how do you implement it properly? We recommend using Collection, ReadOnlyCollection, or KeyedCollection for outputs and properties and interfaces IEnumerable, ICollection, IList for inputs. For example, public ClassA { private Collection<String> strings; publi...

What is the best analogy to help non-oop developers grok interface based programming?

I'm having a hard time trying to get my team comfortable with interface based programming ... anyone have some suggestions? ...

Find java classes implementing an interface

Some time ago, I came across a piece of code, that used some piece of standard java functionality to locate the classes that implemented a given interface. I know the the functions were hidden in some non logical place, but they could be used for other classes as the package name implied. Back then I did not need it, so I forgot about it...

implement an interface with a private method in vb.net

I was kind of shocked by this. Could someone explain why this works? A good example of when to use it would also be nice. Public Interface IFoo Sub DoIt() End Interface Public Class Bar Implements IFoo Private DoIt() implements IFoo.DoIt End Class ... Dim b as new Bar() b.DoIt() 'error CType(b, IFoo).DoIt() 'no error ...

Can I bind multidimensional data to a DataGridView in C# and .NET?

I'm looking to develop an app which features worksheets subclassed from DataGridView. Users can paste (or import) CSV-like data into the worksheet and it will be reflected in a data structure in memory - my first guess would be a 2D array of floats. DataGridView can be bound to objects with a certain set of interfaces (i.e. IList, ILis...

Why prefix C# interface names with “I”

Does anyone know the rationale behind this naming convention? I don't see any benefit. The extra prefix just pollutes the API. I like Konrad Rudolph's response found in this related article ...

Can you require multiple types at once?

Basically I want to do this: public interface A { void a(); } public interface B { void b(); } public class SomeClass { public SomeClass(<A&B> e) { // Note the type here e.a(); e.b(); } } What I did on the commented line is obviously illegal. I know I can just require the passed object to implement inte...

Custom attributes on interfaces or the classes that implement them?

When employing custom attributes to store meta-data, is it best to decorate the interface, or the class that implements the interface, assuming that any class that implements the interface would have the same data in the attribute? Update: Basically i'm writing a custom data storage mechanism for a project, and the objects represent the...

external interface

I have a calc function in java script that takes three integer parameters, following is the AS3 code import flash.external.ExternalInterface; var para:Array = new Array(); send_btn.addEventListener(MouseEvent.CLICK, clickListener); function clickListener(eventObj:Object ):void { para.push(mean.text); para.push(std.text); p...

How to setup an Object Creation Interface "rule" in C#?

The general rule is that I want to say, "T has a method with a String parameter which will return List." Put verbosely, we might call the interface ICanCreateListOfObjectsFromString. A possible application might be search. It feels like it'd be nice to have a static method in my interface, but I know that's not allowed in C#. What is...

How will I know when to create an interface?

I'm at a point in my development learning where I feel like I must learn more about interfaces. I frequently read about them but it just seems like I cannot grasp them. I've read examples like: Animal base class, with IAnimal interface for things like 'Walk', 'Run', 'GetLegs', etc - but I've never been working on something and felt lik...

How to create .NET interface with static members?

In .NET 3.5, I'd like to create a singleton interface: interface ISingleton <T> { public static T Instance {get;} } Of course that doesn't work but is what I'd like. Any suggestions? EDIT: I just want it to be known that all singeltons will have a static property named Instance of the class type. It is always there. An interface w...

Is type checking ever OK?

Is type checking considered bad practice even if you are checking against an interface? I understand that you should always program to an interface and not an implementation - is this what it means? For example, in PHP, is the following OK? if($class instanceof AnInterface) { // Do some code } Or is there a better way of altering ...