interface

Would this be the correct place to use the java keyword "interface" ?

I'm rather new to Java. After just reading some info on path finding, I read about using an empty class as an "interface", for an unknown object type. I'm developing a game in Java based on hospital theme. So far, the user can build a reception desk and a GP's office. They are two different types of object, one is a Building and one is ...

Java: Using a foreign class which conforms to my interface

Hello! Can I take a foreign class in Java which conforms to one of my custom interfaces and "cast" it to that interface? Example: public class YouCanNotChangeMe_IAmNotYours{ public void doSomethingSpecial(); } public interface MyInterface{ void doSomethingSpecial(); } Can I use that foreign class in places where my interfac...

How do I auto-create a code snippet in Visual Studio 2008?

I'm trying to create an interface that automatically implements a fully typed out method in VB.Net However, I can't figure out how to do it. I wanna do something that's similar to what happens when you implement IDisposable, where it gives you the full function, including codes and comments. I know how to make a code snippet and how ...

Why is HashSet<T>.IsReadOnly explicit?

This var h = new HashSet<int>(); var r = h.IsReadOnly; does not compile. I have to do var r = ((ICollection<int>)h).IsReadOnly; why wasn't IsReadOnly implemented normally? (I'm not asking how, but why) ...

Linq to SQL, Entity Framework, Repository Pattern, and Dependency Injection

Hello: Stephan Walters video on MVC and Models is a very good and light discussion of the various topics listed in this questions title. The one question listed in the notes unanswered was: If you create an Interface / Repository pattern for Linq2SQL, does Linq2SQLs classes still cause a dependency on Linq, even though you pass the cl...

Interfaces vs. abstract classes

Duplicate Interface vs Base class With C#, when to use Interfaces and when to use Abstract Classes, what can be the deciding factor. ...

Quick way to insert interface methods to a class in Visual Studio 2005

I know that in Eclipse, if your class implements an interface or extends an abstract class, there is a quick way to add the method definitions to your class. Can this be done with VS2005? How? ...

Reporting Engine Interface

Two interfaces of Reporting Engine are possible: sql based for sql based user non-sql Based interface for normal non-sql friendly users Database is very large so how do I go about thinking about 2) option that is Non-sql based interface How would it be ? ...

implementing interfaces after the fact

I think, the following can't be done in Java. But I would be happy to learn how to implement something that resembles it. Suppose we have a class C, that is already used in compiled code. (We can neither change that code nor the original definition of C). Suppose further there is interesting code that could be re-used, if only C would ...

In Delphi, how can you check if an IInterface reference implements a derived but not explicitly-supported interface?

If I have the following interfaces and a class that implements them - IBase = Interface ['{82F1F81A-A408-448B-A194-DCED9A7E4FF7}'] End; IDerived = Interface(IBase) ['{A0313EBE-C50D-4857-B324-8C0670C8252A}'] End; TImplementation = Class(TInterfacedObject, IDerived) End; The following code prints 'Bad!' - Procedure Test; Var A : ...

Describing what an Interface is for?

How would you describe the purpose of an Interface to a student-class that understand basic OOP design? ...

Enforcing dependencies in IoC via a constructor?

I'm trying to come to terms with using IoC/Dependency Injection while at the same time programming to contracts rather than specific classes. The dilemma I'm having is the tension between: Do program to interfaces for IoC: I started out with IoC relying heavily on interfaces. Judging by Spring's sample projects, interfaces are the way ...

How to name a collection of an interface?

The situation is as follows. public interface IFoo { } public abstract class FooBase : IFoo { } Now I need a collection of IFoo with some additional methods. public class IFooCollection : List<IFoo> { public void UsefullMethod() { } } The problem is that IFooCollection looks like an interface while it is a class. The options ar...

Comment the interface, implementation or both?

I imagine that we all (when we can be bothered!) comment our interfaces. e.g. /// <summary> /// Foo Interface /// </summary> public interface Foo { /// <summary> /// Will 'bar' /// </summary> /// <param name="wibble">Wibble factor</param> void Bar(string wibble); } Do you also comment the implementation (which may...

Interface vs Abstract Class (general OO)

Hi, I have had recently two telephone interviews where I've been asked about the differences between an Interface and an Abstract class. I have explained every aspect of them I could think of, but it seems they are waiting for me to mention something specific, and I dont know what it is. From my experience I think the following is tru...

Reflecting on interfaces of a type in C#

How can I reflect on the interfaces implemented by a given type (of class or interface) in .NET? As the type being reflected on will be generic (both in the implementation sense as well as the semantic sense), it would preferable to do this without having to hardcode an Assembly name, though I realise that I can get this name from the ...

Generics with interfaces in F#

In C# one can state that a generic parameter must implement a certain interface like so: public class Something<T> where T : IComparable { ... } How does one specify this in F#? ...

Is it possible to make a parameter implement two interfaces?

Is it possible to define a function that takes in a parameter that must implement two interfaces? (The two interfaces are ones I just remembered off the top of my head; not the ones I want to use) private void DoSomthing(IComparable, ICollection input) { } ...

C# Accept object with Interface1 and Interface2

Duplicate: Is it possible to make a parameter implement two interfaces? Looking for a way to do this : public interface INumber1 {} public interface INumber2 {} public class TestObject : INumber1, INumber2 {} public static class TestClass { public static void TestMethod(INumber1&INumber2 testobject) { ... } ...

Casting Interfaces with ILIST

I have field X of type ILIST <ITopics> I am trying to do this: Object.X= AListOfSometypeThatInheretsITopics; How do I properly cast the list to the Object.X? ...