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?
...
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...
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...
Should my interface and concrete implementation of that interface be broken out into two separate files?
...
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...
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...
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.
///...
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...
I'm having a hard time trying to get my team comfortable with interface based programming ... anyone have some suggestions?
...
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...
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
...
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...
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
...
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...
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...
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...
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...
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...
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 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 ...