interface

what is the difference between IShell shell = new... and Shell shell = new....

I'm working through the Composite Application Guidance and often come across instantiation of an object of type interface e.g.: IShell shell = new Shell(); instead of type class: Shell shell = new Shell(); What are the differences between these two? Why is the first way used at all (since the second shell object can be used anywh...

web service can't serialize an interface

I have an interface like so: public interface IDocument : ISerializable { Boolean HasBeenUploaded { get; set; } void ISerializable.GetObjectData(SerializationInfo, StreamingContext) { } } There are three documents that inherit from this, all of which serialize just fine. But when creating a simple web service, that does nothin...

How can I have a class that implements an interface and inherits from an abstract class? (C# .NET 3.5)

I have a situation which I think I need the functionality provided by an interface and an abstract class. I am creating models to be used in a simulation. Each model is contained in a C# class that implements an IModel interface (of my design so it can be modified). I also created a c++ unmanaged Win32 DLL that acts as a bridge between ...

What is the purpose of interfaces?

I want to understand the purpose of interfaces. I know how to declare an interface and how to implement the interface, but what is the need of it? I need to understand the reason for using interfaces. In every programming course, the teacher has said, "It is a contract. It has just definitions of methods and properties," and given an exa...

OCaml types with different levels of specificity

I am attempting to simulate an interface in OCaml and am using the "type" construct. I have two types: type fooSansBar = {a: string; b: int};; type fooConBar = {a:string; b:int; bar:char};; ...and would like to define a particular fooSansBar: let fsb = {a="a"; b=3};; ...but am told that the bar field is not defined. From this, it a...

Fluent NHibernate, working with interfaces

I just switched to Fluent NHibernate and I've encountered an issue and did not find any information about it. Here's the case : public class Field : DomainObject, IField { public Field() { } public virtual string Name { get; set; } public virtual string ContactPerson { get; set; } public virtual bool Private ...

Use an interface from an external assembly that's marked as "internal" (C#)

I'd like to implement an interface that resides in an external assembly. However that particular interface has been marked as "internal". Is there a way I can still implement this interface for my own classes? I know how to call private/internal methods using reflection in C#, so I guess reflection should be used in this case too. Howev...

Scala and interfaces

In Java I would typically declare my entire domain as interfaces, possibly with some kind of Factory to get me implementations. This is partly because I am so old I can remember when some persistence layers required implementation classes to subclass a specific class but also so that I can easily: mock objects for testing purposes prox...

NHibernate - Is it OK to use an abstract base to provide functionality instead of an interface?

I'm fairly new to NHibernate and have run into a strange inheritance chaining issue with my repository classes. I've been using Gabriel Schenker's FAQ as a reference, and following his examples I've been creating interfaces to define contracts for DAO operations in "repository" classes. The data schema I'm working with is rather extens...

Null reference when performing foreach loop with Interfaces ASP.Net Cluster Environment

I have a List in a web control when the control creates it's child controls I perform a foreach loop through the list of fields as foreach (IField field in this._fields) { /* Do some work here */ } Localhost, out dev environment, and our staging environment everything is fine. But when we deploy to our dev cluster each "field" is...

Data Binding on Custom Class

I'm trying to create a custom class that is based off of an XML file (using xsd.exe). The end goal of this class is to bind it to a UI element (probably a gridview or something like that - I haven't decided yet). Are there any interfaces that I need to be sure to implement in order to do this? I would think IEnumerable would be a key one...

What's the difference between an interface and an abstract class?

Duplicate: When to use an interface instead of an abstract class and vice versa? Probably one of the most famous software developer job interview questions. What would be your answer? EDIT: I'm trying to find out how you would answer this in a real-life situation. Please try to formulate your answer as you would on a real job int...

Interface naming convention

This is a subjective thing of course, but I don't see anything positive in prefixing interface names with an 'I'. To me, Thing is practically always more readable than IThing. My question then is, why does this convention exist anyway? Indeed, it makes easier to identify interfaces among all types. But wouldn't a similar argument extend...

Do I need an abstract class or interface here (or neither)?

I have a warehouse. Sometimes I want to lookup a box location by a name, sometimes by a description, sometimes by a UPC, maybe something else, etc. Each of these lookup methods call the same various private methods to find information to help locate the data. For example, upc calls a private method to find a rowid, so does name, so do...

Using interfaces on abstract classes in C#

I'm learning C# coming from C++ and have run into a wall. I have an abstract class AbstractWidget, an interface IDoesCoolThings, and a class which derives from AbstractWidget called RealWidget: public interface IDoesCoolThings { void DoCool(); } public abstract class AbstractWidget : IDoesCoolThings { void IDoesCoolThings.DoCo...

How do i make sure that a datatype implement an IComparable interface

I need to make sure that a datatype implements the IComparable interface, and I was wondering if there was anyway to make that a requirement when you create the object? ...

Documenting and Architectural Modeling of Interface Dependencies

I have a large software system with millions of SLOC, hundreds of modules, and thousands of interface dependencies. Based upon an earlier question in StackOverflow I have been able to start discovering what these interface dependencies actually are. The challenge now is to have all this information available in a useful format. The da...

Why does interface allow declaring states in interface?

According to an answer for Why are we not allowed to specify a constructor in an interface?, Because an interface describes behaviour. Constructors aren't behaviour. How an object is built is an implementation detail. If interface describes behavior, why does interface allow declaring state? public interface IStateBag { object...

.Net: Using a Webservice as an interface for a Data Access Layer

I am currently doing a CRUD project for school and basically they want us to have this kind of structure (3 projects): Class Library Contains all the Data Access logic (Retrieving the data from the database with either Linq of standard ADO.Net) Web Service Having a refere...

Can I abstract Entity Framework away from my Entities?

I have a Foo entity in Entity Framework. But I'm making it inherit from IFoo so that my business logic only knows IFoo - thus abstracting Entity Framework away. The problem is that Foo has a collection of Bar entities. And this collection is of type EntityCollection<Bar> . If I put this collection in IFoo as it is, I make IFoo depende...