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...
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...
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 ...
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...
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...
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 ...
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...
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...
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...
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...
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...
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...
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...
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...
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...
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?
...
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...
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...
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...
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...