interface

Providing a common interface to SVN and CVS

SVN and CVS are two very different systems that aim to address the same basic issue - source control. They both work in distinct ways, so it's probably difficult to deal with them exactly the same. What I'm wondering is, would it be conceivable to develop a programming library or API that exposes the same interface, but under the hood,...

Why can I not return a List<Foo> if asked for a List<IFoo> ?

I understand that, if S is a child class of T, then a List<S> is not a child of List<T>. Fine. But interfaces have a different paradigm: if Foo implements IFoo, then why is a List<Foo> not (an example of) a List<IFoo>? As there can be no actual class IFoo, does this mean that I would always have to cast each element of the list when exp...

How do you declare an interface in C++?

How do I setup a class that represents an interface? Is this just an abstract base class? ...

is combined generic bounds an anti pattern?

as a follow up on my previous question Having a function with combined generic bounds such as: <T extends Foo & Bar> void doStuff(T argument) { //do stuff wich should only be done if arguments is both foo and bar } Because this is not castable from a unspecified object, you need to have knowledge of some object which actually implem...

Interfaces with static fields in java for sharing 'constants'

I'm looking at some open source Java projects to get into Java and notice a lot of them have some sort of 'constants' interface. For instance, processing.org has an interface called PConstants.java, and most other core classes implement this interface. The interface is riddled with static members. Is there a reason for this approach, or...

Passing interface as a parameter to an extension method

I have used extension methods to extend html helpers to make an RSS repeater: public static string RSSRepeater(this HtmlHelper html, IEnumerable<IRSSable> rss) { string result=""; foreach (IRSSable item in rss) { result += "<item>" + item.GetRSSItem().InnerXml + "</item>"; } ...

How do I setup up JFileChooser for single click behavior in java Swing?

Hello How do I change the JFileChooser behavior from double-click selection to single-click selection mode? I'm developing an application to run with either a single-click interface (nothing requires a double-click, just like the KDE interface mode) or a double-click interface (the default Windows interface mode or the regular GNOME in...

Class inherits generic dictionary<string, IFoo> and Interface

I have a class that inherits a generic dictionary and an inteface public class MyDictionary: Dictionary<string, IFoo>, IMyDictionary { } the issue is that consumers of this class are looking for the '.Keys' and ".Values" properties of the interface so i added: /// <summary> /// /// </summary> ICollection<string> Keys...

Whats the best (most useful) interface you have written?

The title basically spells it out. What interfaces have you written that makes you proud and you use a lot. I guess the guys that wrote IEnumerable<T> and not least IQueryable<T> had a good feeling after creating those. ...

Implementing event conditions in a C++ state machine

I'm using an hierarchical FSM for an embedded C++ application interface. I'd like to use small functions to determine whether certain inter-state events can be triggered, as well as use them to effect changes in the database: however, making a new class with different event functions for each state is daunting, as well as setting pointer...

IoC & Interfaces Best Practices

I'm experimenting with IoC on my way to TDD by fiddling with an existing project. In a nutshell, my question is this: what are the best practices around IoC when public and non-public methods are of interest? There are two classes: public abstract class ThisThingBase { public virtual void Method1() {} public virtual void Method...

Programming to an interface. How to decide where its needed?

I understand that programming to interfaces helps with loose coupling. However, is there a guideline that explains when its most effective? For example, I have a simple web application that collects data on employees, their training plans, expenses and computes their expense for the year etc. This is a fairly simple application and I ca...

How can I get a list of all the implementations of an interface programmatically in Java?

Can I do it with reflection or something like that? ...

What is the difference between Moq-ing a class or interface?

I've been using moq to mock objects in my unit tests and I've seen on the site about moq that it is able to mock both classes and interfaces. I had a discussion with one of my work mates the other day and they stated that there is never a reason to mock classes and I should only mock interfaces. I didn't really have an answer to that.....

check whether an array is multidimensional

Hello, as I am implementing the ICollection-Interface in my class I want to implement the CopyTo-Method and I have to throw an Argument-exception if the array is multidimensional. What is meant by this? The head of my method is this public void CopyTo(MyClass[] array, int arrayIndex) I thought these brackets would mean that the given...

What (not) to declare when implementing an interface with an abstract class?

I have an interface A, for which I have to supply a few different implementations. However, those implementations share some helper methods, so I moved those methods to an abstract base class. Interface A { void doX(); } abstract Class B implements A { protected void commonY() { // ... } @Override public abstract void doX(); } ...

Should every single object have an interface and all objects loosely coupled?

From what I have read best practice is to have classes based on an interface and loosely couple the objects, in order to help code re-use and unit test. Is this correct and is it a rule that should always be followed? The reason I ask is I have recently worked on a system with 100’s of very different objects. A few shared common inter...

VB.NET Creating Classes, What is Public Class MyClass(Of Type) ?

I'm still learning ASP.NET and I often see code like this throughout parts of our framework: Public MustInherit Class DBFileManager(Of F As IDBFile, FC As IDBFileContent, FT As IDBFileThumb) Can anybody tell me what this means? Much thanks! ...

Enforcing serializable from an interface without forcing classes to custom serialize in C#.

I have an interface that defines some methods I would like certain classes to implement. public interface IMyInterface { MethodA; MethodB; } Additionally I would like all classes implementing this interface to be serializable. If I change the interface definition to implement ISerializable as below...: public interface IMyI...

Should an interface that is inherited from base-class be implemented explicitly in subclass?

My question is, if an interface that is implemented implicitly by extending a class that already implements it, should be explicitly implemented by the class, if the class wants to advertise the fact, that it fulfills the contract of that interface. For instance, if you want to write a class, that fulfills the contract of the interface...