inheritance

Inheritance in database?

Is there any way to use inheritance in database (Specifically in SQL Server 2005)? Suppose I have few field like CreatedOn, CreatedBy which I want to add on all of my entities. I looking for an alternative way instead of adding these fields to every table....

Inheritance and Polymorphism - Ease of use vs Purity

In a project our team is using object lists to perform mass operations on sets of data that should all be processed in a similar way. In particular, different objects would ideally act the same, which would be very easily achieved with polymorphism. The problem I have with it is that inheritance implies the is a relationship, rather th...

How can I override an EJB 3 session bean method with a generic argument - if possible at all?

Suppose you have the following EJB 3 interfaces/classes: public interface Repository<E> { public void delete(E entity); } public abstract class AbstractRepository<E> implements Repository<E> { public void delete(E entity){ //... } } public interface FooRepository<Foo> { //other methods } @Local(FooRepository....

Is it a bad idea to expose inheritance hierarchy in namespace structure?

I've got a group of inter-related classes that are all overridden together to create a particular implementation. I'm wondering if it is a good idea to enclose the interrelated subclasses in a namespace. For example purposes, consider the following namespaces and classes: namespace Protocol { public abstract class Message { } publi...

XML Serialization and Inherited Types

Hi Guys, following on from my previous question I have been working on getting my object model to serialize to XML. But I have now run into a problem (quelle surprise!). The problem I have is that I have a collection, which is of a abstract base class type, which is populated by the concrete derived types. I thought it would be fine to...

Is there a way to make a constructor only visible to a parent class in C#?

I have a collection of classes that inherit from an abstract class I created. I'd like to use the abstract class as a factory for creating instances of concrete implementations of my abstract class. Is there any way to hide a constructor from all code except a parent class. I'd like to do this basically public abstract class Abstract...

What is the best way to inherit an array that needs to store subclass specific data?

I'm trying to set up an inheritance hierarchy similar to the following: abstract class Vehicle { public string Name; public List<Axle> Axles; } class Motorcycle : Vehicle { } class Car : Vehicle { } abstract class Axle { public int Length; public void Turn(int numTurns) { ... } } class MotorcycleAxle : Axle { public bool W...

Accessing a Component on an inherited form from the base form

A number of forms in my project inherit from a base form. It is easy to get at the Controls collection of the derived forms, but I have not found a simple way to access the Components collection, since VS marks this as private. I assume this could be done with reflection, but I'm not really sure how best to go about it, not having work...

Preventing XML Serialization of IEnumerable and ICollection<T> & Inherited Types

NOTE: XMLIgnore is NOT the answer! OK, so following on from my question on XML Serialization and Inherited Types, I began integrating that code into my application I am working on, stupidly thinking all will go well.. I ran into problems with a couple of classes I have that implement IEnumerable and ICollection<T> The problem with the...

Are there any examples where we *need* protected inheritance in C++?

While I've seen rare cases where private inheritance was needed, I've never encountered a case where protected inheritance is needed. Does someone have an example? ...

Does C# have the notion of private and protected inheritance?

Does C# have the notion of private / protected inheritance, and if not, why? C++ class Foo : private Bar { public: ... }; C# public abstract NServlet class : private System.Web.UI.Page { // error "type expected" } I am implementing a "servlet like" concept in an .aspx page and I don't want the concrete class to hav...

Class design decision

I have a little dilemma that maybe you can help me sort out. I've been working today in modifying ASP.NET's Membership to add a level of indirection. Basically, ASP.NET's Membership supports Users and Roles, leaving all authorization rules to be based on whether a user belongs to a Role or not. What I need to do is add the concept of...

How can I simply inherit methods from an existing instance?

Hi, below I have a very simple example of what I'm trying to do. I want to be able to use HTMLDecorator with any other class. Ignore the fact it's called decorator, it's just a name. import cgi class ClassX(object): pass # ... with own __repr__ class ClassY(object): pass # ... with own __repr__ inst_x=ClassX() inst_y=ClassY() ...

Why @OneToMany does not work with inheritance in Hibernate

@Entity @Inheritance(strategy = InheritanceType.SINGLE_TABLE) public class Problem { @ManyToOne private Person person; } @Entity @DiscriminatorValue("UP") public class UglyProblem extends Problem {} @Entity public class Person { @OneToMany(mappedBy="person") private List< UglyProblem > problems; } I think it is pretty...

Why doesn't inheritance work the way I think it should work?

I'm having some inheritance issues as I've got a group of inter-related abstract classes that need to all be overridden together to create a client implementation. Ideally I would like to do something like the following: abstract class Animal { public Leg GetLeg() {...} } abstract class Leg { } class Dog : Animal { public overrid...

Prefer composition over inheritance?

Why prefer composition over inheritance? What trade-offs are there for each approach? When should you choose inheritance over composition? ...

Does Delphi call inherited on overridden procedures if there is no explicit call

Does Delphi call inherited on overridden procedures if there is no explicit call in the code ie (inherited;), I have the following structure (from super to sub class) TForm >> TBaseForm >> TAnyOtherForm All the forms in the project will be derived from TBaseForm, as this will have all the standard set-up and destructive parts that are ...

C++ inheritance and member function pointers

In C++, can member function pointers be used to point to derived (or even base) class members? EDIT: Perhaps an example will help. Suppose we have a hierarchy of three classes X, Y, Z in order of inheritance. Y therefore has a base class X and a derived class Z. Now we can define a member function pointer p for class Y. This is writ...

How to remove this parallel hierarchy

I'm trying to find the best design for the following scenario - an application to store results of dance competitions. An event contains multiple rounds, each round contains a number of performances (one per dance). Each performance is judged by many judges, who return a scoresheet. There are two types of rounds, a final round (contai...

Can a LINQ to SQL IsDiscriminator column NOT inherit?

I'm designing my database and LINQ To SQL ASP.NET web application. Imagine I have two types of pages: normal and root. Some pages are roots. Some pages are not. I have a Page database table and a RootPage database table: Page ---- PK PageId HtmlTitle PageHeading MetaDescription IsRoot R...