interface

How do I implement a common interface for Django related object sets?

Here's the deal: I got two db models, let's say ShoppingCart and Order. Following the DRY principle I'd like to extract some common props/methods into a shared interface ItemContainer. Everything went fine till I came across the _flush() method which mainly performs a delete on a related object set. class Order(models.Model, interface...

Why can't I have protected interface members?

What is the argument against declaring protected-access members on interfaces? This, for example, is invalid: public interface IOrange { public OrangePeel Peel { get; } protected OrangePips Seeds { get; } } In this example, the interface IOrange would guarantee that implementors at least provide an OrangePips instance to their...

After restricting Setter scope and then applying an interface, scope is disregarded!

If I set a Friend-level scope on a setter, like this... Public Class MyClass Public Property IsDirty() As Boolean Get Return _isDirty End Get Friend Set(ByVal trueFalse As Boolean) _isDirty = trueFalse End Set End Property End Class ...And then call it from another proje...

LinkedList(T) add-method

The Add-method from the ICollection(T) interface has been explicitly implemented by the LinkedList(T)-class. This collection instead have AddFirst- and AddLast-methods (among others). The explicitly implemented method maps to the AddLast-method. This has some drawbacks and IMHO no benefit at all. The two major drawbacks are this: You c...

Limiting the data returned by a controller

I need advice on how to return a limited set of data from an MVC controller. Lets say I have a class that is constructed like so: public interface ICustomerExpose { string Name {get; set;} string State {get; set;} } public interface ICustomer: ICustomerExpose { int Id {get; set;} string SSN {get; set;} } public class Cust...

How to get interface basetype via reflection?

public interface IBar {} public interface IFoo : IBar {} typeof(IFoo).BaseType == null How can I get IBar? ...

Binding IList<IMyInterfaceType> doesn't display members of Interfaces that IMyInterface inherits

I'm binding IList to a GridView. IMyInterface looks like public interface IMyInterface: IHasTotalHours, IHasLines { DateTime GoalStartDate { get; set; } DateTime GoalEndDate { get; set; } } I bind an instance to a Grid like this: IList<IMyInterface> instance= GetMyData(); myGrid.DataSource = instance; myGrid.DataBind(); Wh...

Adding Plugin Support : Interface or Base class to inherit?

I'm adding plugin support to my .NET application. A base class sounds reasonable to me, so people can inherit it and override certain calls as well can keep the default functionality or can use some internal helper functions. Why would I choose interface instead of a base plugin class to inherit? Could you tell which design I should ch...

Groovy: Delegating metaclass for an Interface?

Using Groovy's package name convention, I can intercept Groovy method calls to a Java method like so: package groovy.runtime.metaclass.org.myGang.myPackage class FooMetaClass extends groovy.lang.DelegatingMetaClass { StringMetaClass(MetaClass delegate) { super(delegate); } public Object getProperty(Object a, St...

Freakishly weird interface polymorphism using interface composition

I ended up with something like the following code in a project I'm working on. I thought it was really odd that I was allowed to do it, but now I'm starting wonder what is most likely an architectural gaff on my part led me to this. My questions to you are: What exactly is this called? What are some real world uses of this? Why would...

How to declare a variable/param of type "Control implementing interface ISomething"?

I wish to declare a variable in such a way as it can be assigned only values which derive from Control and also implement the ISomething interface. I intend to add the ISomething interface to derivatives of controls. I would like to derive SpecialTextBox and SpecialDatePicker From TextBox and DatePicker and implement the ISomething in...

Generic implementation of interface

Hi everyone! Why isn't this working ? public interface IPoint { // not important } public interface IPointList { List<IPoint> Points { get; } } public abstract class Point : IPoint { // implemented IPoint } public abstract class PointList<TPointType> : IPointList where TPointType: IPoint { public abstract List<TPointType> P...

Who/What implements Interfaces that I can use directly?

I came across several interfaces while learning JDBC - Connection, Statement, ResultSet etc... Does this imply that some classes somewhere, hidden from me, are implementing these interfaces, and providing their references when I need it? Is this because they need to be implemented differently depending on the Driver I'm using? ...

"Interfaces" in Python: Yea or Nay?

So I'm starting a project using Python after spending a significant amount of time in static land. I've seen some projects that make "interfaces" which are really just classes without any implementations. Before, I'd scoff at the idea and ignore that section of those projects. But now, I'm beginning to warm up to the idea. Just so we...

PHP Interfaces

I have defined an interface for a data structure type. I am trying to force whatever class implementing that interface to also implement two other interfaces (iterator and countable). Is there a way to do this? ...

Raising Events From Interface (win forms)

Hi All, My scenario: Windows Forms Application with a base master (mdi) form. Public Interface IDoSomething that has an event: Event AddFilter() Modal popup window implements the interface and decalres event: Public Class frmPopup Implements IDoSomething Public Event AddFilter() Implements IDoSomething.AddFilter Popup also conta...

ASP.NET: Unfamiliar with Interfaces

I'm building a decent sized application in ASP.NET/VB.NET with various objects... I've never used interfaces before, and a fellow programmer balked when I mentioned this to him. Can anyone give me a quick overview on how they're used, what they're used for, and why I would use them? Maybe I don't need to use them for this project, but if...

How do you decide between using an Abstract Class and an Interface?

Duplicate: http://stackoverflow.com/questions/56867/interface-vs-base-class I have been getting deeper into the world of OOP, design patterns, and actionscript 3 and I am still curious how to know when to use an Abstract class (pseudo for AS3 which doesn't support Abstract classes) and an interface. To me both just serve as templates...

Do you define an interface for every public class in your domain model? Pros and Cons?

Do you implement an interface for every public class in your domain model? Pros and Cons? Update: If Repositories interfaces and domain model classes are defined in separate assemblies, wouldn't there be circular dependency if we do not define interfaces for every domain class. ...

.NET remoting, versioning and interfaces

I have a large .NET remoting project using the 2.0 framework. The server's API is exposed via interfaces and shared types are contained in an assembly shared with the client application. I have some methods that accept arrays of a base class that has many different classes inheriting from it. For example I have base class "Vehicle" tha...