interface

Linqtosql - Returning custom class with interface

Why can't I return as a new custom class (cms.bo.Site) which implements ISite? public IQueryable<ISite> GetSites() { return (from site in Db.Sites select new cms.bo.Site(site.id, site.name)); } ...

ATL/COM: Can I have the same function in two different interfaces of the same object?

I have an ATL/COM-based DLL, written in VC++ 6.0. Until recently, there was a one-to-one correspondence between my COM interfaces and classes. For example, let's say there was a ICar interface; then there was also a CCar class which implemented it, and no class other than CCar implemented ICar, and CCar implemented no interface (of min...

Connection and Collection Interfaces in Java

Which class implements all the Connection Interfaces which are in javax.microedition.io package and how? And in the same way which class implements the some of Collection interfaces like Iterator interface. I saw a code: - Iterator it; ArrayList list = new ArrayList(); it = list.iterator(); The iterator() return type is "Iterator"...

C#-Events of interface practical use

Can you give a good example of the power of interface -events (declaring events inside interface)?Most of the times i have seen only public abstract methods inside interface. Thanks. ...

are scenarios/stories the new interface in BDD/TDD?

PHP is somewhat crippled since it doesn't have return types (yet). I need my code to throw an exception when X already exists. I can write this in a scenario, but I'm not able to go from the scenarios to the interface my class should implement. Actually this problem is the same in TDD I guess. There seems more that I can tell through my...

Creating good interfaces, what should be included and what should be left out

I am in the process of updating a website for the third time in in 2 years, looks like this is going to happen all of the time and several websites are using the same DB. I want to use the same code for all of them and keep it easy to update in the future. So I plan on writing some interfaces and then place the business login in a serv...

Java : How to create a function that can only accept object which is an Interface?

I need to write a function that accepts an object , but I want to enforce in the function call (not after the function is called) that the object is an interface. Meaning , I want to make sure this is an Interface at compile time , not on run time. What do I mean? interface ISomething {...} class A implements ISomething { ... } ISo...

Adding functionality by adding new interfaces instead of extending existing ones

I need to add some new functionality to an existing interface. There are already a lot of classes in the project implementing it but a few of them wouldn't need the new set of features. My first approach was to just add the new functions to the existing interface and implementing it everywhere, adding do-nothing functions where applicabl...

Share & Embed Widget design samples?

I am searching for some sample interface or design for creating a "Share & Embed Widget or Link" interface in my website. I found scribd.com's interface interesting http://www.scribd.com/doc/22735617/Senate-Health-Care-Bill here click on "Share & Embed" link given in top-right of the doc. Could any one please provide me some sample li...

Dynamically implement interface in Groovy using invokeMethod

Groovy offers some really neat language features for dealing with and implementing Java interfaces, but I seem kind of stuck. I want to dynamically implement an Interface on a Groovy class and intercept all method calls on that interface using GroovyInterceptable.invokeMethod. Here what I tried so far: public interface TestInterface { ...

Server command via AJAX interface

Hi I'm new on AJAX. Just for fun I'm trying to control my sever via an AJAX interface. It's quite easy, for instance in PHP, to send a command to the server by the system() function and just a text field and a submit button. The thing I'd like to do is to control in realtime some action, for example controlling music volume by a web in...

Cast concrete class to generic base interface

Here's the scenario i am faced with: public abstract class Record { } public abstract class TableRecord : Record { } public abstract class LookupTableRecord : TableRecord { } public sealed class UserRecord : LookupTableRecord { } public abstract class DataAccessLayer<TRecord> : IDataAccessLayer<TRecord> where TRecord : Record, n...

What is the Class Of List<Foo> in Java?

Class c = List<Foo>.class doesn't seem to work. ...

How to use generic class (or interface) in another generic class (or interface) with the same data type parameters without casting

I need the Cache class that keep the <TKey key, TValue value> pairs. And it is desirable that TKey can be any class that supports Serializable interface and TValue can be any class that supports Serializable and my own ICacheable interfaces. There is another CacheItem class that keeps <TKey key, TValue value> pair. I want the Cache cla...

How to access derived class members from an interface?

I have three classes; Stamp, Letter and Parcel that implement an interface IProduct and they also have some of their own functionality. public interface IProduct { string Name { get; } int Quantity { get; set; } float Amount { get; } } public class Stamp : IProduct { public string Name { get { return "Stamp"; } } ...

How to centrally define IComparable on abstract (interface) types in F#

This question is kind of the next level of http://stackoverflow.com/questions/895769/f-set-using-custom-class -- I want to define IComparable for a generic interface. I have an arbitrary set of types which implement a shared metadata exchange interface, ITree. I want to compare across these types, using only the exposed data in ITree. ...

Using is operator with Interface to Generics

I have a few generic classes that implement a common non-generic interface. I create my generic objects and add them to a list. How can I use LINQ, or any other method for that matter, to filter the list by the generic type. I do not need to know T at run-time. I added a type property to the interface and used LINQ to filter by it but I ...

How to get a base class method return type to be the subclass type?

I have a copy function that I'd like to override in subclasses to return the type of the subclass. Here are my interfaces: Public Interface IBase(Of T) Function Copy() As T End Interface Public Interface ICar Inherits IBase(Of ICar) End Interface Public Interface IToyota Inherits ICar End Interface And here are my classe...

Iphone interface question

Just curious if I need to implement a way for the user to get back to the main screen of a program. It's actually essential in my app for the user not to be able to get back. Will this get rejected if I don't add a back button? ...

What is the value of Interfaces?

Sorry to ask sich a generic question, but I've been studying these and, outside of say the head programming conveying what member MUST be in a class, I just don't see any benefits. ...