inheritance

How to Access a descendant object's internal method in C#

I'm trying to access a method that is marked as internal in the parent class (in its own assembly) in an object that inherits from the same parent. Let me explain what I'm trying to do... I want to create Service classes that return IEnumberable with an underlying List to non-Service classes (e.g. the UI) and optionally return an IEnum...

C# Lack of Static Inheritance - What Should I Do?

Alright, so as you probably know, static inheritance is impossible in C#. I understand that, however I'm stuck with the development of my program. I will try to make it as simple as possible. Lets say our code needs to manage objects that are presenting aircrafts in some airport. The requirements are as follows: There are members and ...

Object hierarchy returned by WCF Service is different than expected

Good Day Everyone... My understanding may be wrong, but I thought once you applied the correct attributes the DataContractSerializer would render fully-qualified instances back to the caller. The code runs and the objects return. But oddly enough, once I look at the returned objects I noticed the namespacing disappeared and the object-...

Question about design (inheritance, polymorphism)

Hi, I have a question about a problem I'm struggling with. Hope you can bear with me. Imagine I have an Object class representing the base class of a hierarchy of physical objects. Later I inherit from it to create an Object1D, Object2D and Object3D classes. Each of these derived classes will have some specific methods and attributes....

Compile error on inheritance of generic inner class extending with bounds

I have a problem when compiling a generic class with an inner class. The class extends a generic class, the inner class also. Here the interface implemented: public interface IndexIterator<Element> extends Iterator<Element> { ... } The generic super class: public abstract class CompoundCollection<Element, Part extends Collecti...

Ruby get inheriting class

I'm working on creating my first plugin for rails. I'm still pretty new to ruby and I was wondering if its possible to get the inheriting class? For example, I'm trying to create a plugin that will allow unit testing and functional testing when you are not using migrations. What I'm trying to do is initialize a class variable named cont...

Doctrine: Mixing YAML markup and db manager (navicat) editing?

I think the answer to this question should be: No. However I hope to be corrected. I'd like to edit our database using a mixture of YAML markup + Doctrine createTables() and Navicat editing. Can I maintain the inheritance which is marked up? Example (4 steps, at step 4, Doctrine is in no way able to re-create the inheritance schema... ...

JPA : Inheritance - Discriminator value not taken into account in generated SQL

I try to use this mapping : @Entity @Table(name="ecc.\"RATE\"") @Inheritance(strategy=InheritanceType.SINGLE_TABLE) @DiscriminatorColumn(name="DISCRIMINATOR", discriminatorType= DiscriminatorType.STRING) public abstract class Rate extends GenericBusinessObject { ... } @Entity @DiscriminatorValue("E") public class EntranceRate extends R...

Passing List (Of ChildClass) as parameter to method expecting List (Of ParentClass)?

Hi, I have implemented inheritance for two parent classes called Table and Field. Each parent class has several child classes. In the Table parent class, I created a method that expects parameter List(Of Field). I get an error when trying to pass in parameter List(Of ChildField) to the method that expects a parameter of List(Of Field). ...

Hibernate: What's wrong with this mapping to a subclass joined on foreign key?

I am experimenting with Hibernate to gain experience. I created a class Person with two subclasses: Student and Worker: public abstract class Person { private Long id; ... } public class Student extends Person { ... } Another class, Employer, has a bidirectional one-to-many relationship with Worker. public class Worker exten...

How to return children objects?

I have -- what I think -- is a simple question. Here's my code: class Fruit < ActiveRecord::Base end class Apple < Fruit end class Kiwi < Fruit end Assume that I have all the STI setup correctly, and there are multiple types of Apple and Kiwi records in the table. From here... fruits = Fruit.find(:all) ...how do I return an arr...

Java inheritance question

I have an abstract class Airplane, and two classes PassengerAirplane and CargoAirplane, which extend class Airplane. I also have an interface Measurable, and two classes that implement it - People and Containers. So, Airplane can do many things on its own, and there is a method which allows measurable things to be added to the airplane (...

Silverlight with MVVM Inheritance: ModelView and View matching the Model

Hello Stackoverflowers! :) Today I have a special question on Silverlight (4 RC) MVVM and inheritance concepts and looking for a best practice solution... I think that i understand the basic idea and concepts behind MVVM. My Model doesn't know anything about the ViewModel as the ViewModel itself doesn't know about the View. The ViewMode...

C++ enforce conditions on inherited classes

I would like to define an abstract base class X and enforce the following: a) every concrete class Y that inherits from X define a constructor Y(int x) b) it should be possible to test whether two Y objects are equal. For a, one not very good solution is to put a pure virtual fromInt method in X which concrete class will have to defi...

Compile time type determination in C++

A coworker recently showed me some code that he found online. It appears to allow compile time determination of whether a type has an "is a" relationship with another type. I think this is totally awesome, but I have to admit that I'm clueless as to how this actually works. Can anyone explain this to me? template<typename BaseT, typenam...

Placement of a call to the parent method

I have a class that has a method. That class has a child class that overrides that method. The child's method has to call the parent's method. In all OO that I've seen or written calls to the parent's version of the same method were on the first line of the method. On a project that I am working on circumstances call for placing that met...

Instantiate a inherited class using a static method from a base class.

I have a abstract base class that I have many inherited classes coming off of. What I would like to do is a static member takes in a string, the first class that can parse the string (only one of the inherited classes should be able to) and return a instance of the inherited class. This is what i am currently doing. public static Epl2C...

Populating Models from other Models in Django?

This is somewhat related to the question posed in this question but I'm trying to do this with an abstract base class. For the purposes of this example lets use these models: class Comic(models.Model): name = models.CharField(max_length=20) desc = models.CharField(max_length=100) volume = models.IntegerField() ... <50 o...

Generics vs inheritance (when no collection classes are involved)

This is an extension of this questionand probably might even be a duplicate of some other question(If so, please forgive me). I see from MSDN that generics are usually used with collections The most common use for generic classes is with collections like linked lists, hash tables, stacks, queues, trees and so on where operati...

Can I reuse a column across subclasses in a Hibernate table-per-hierarchy inheritance strategy?

In a simple inheritance tree, an abstract superclass has two subclasses. The subclasses both store a key-value pair, but but one will be holding a type Encrypted String, and the other one a plain old String. Now, my question is can I do this: @Entity @Inheritance(strategy = InheritanceType.SINGLE_TABLE) public abstract Attribute { ...