Relative Content

Tag Archive for inheritance

Inheritance and constricted referencing

Let’s say I have BaseA and BaseB classes. BaseB can have to several references of BaseA instances. Now, we have two other classes, DerivedA and DerivedB that respectively inherit from BaseA and BaseB.

What principle of OOAD is this pattern breaking?

I’m trying to make a case for not putting the structure in the parent BaseModule class I’ve shown below. I’m more for a Strategy Pattern, and minimizing inheritance in favor of has-a relationships, but I am not really sure of what principle of OOAD this pattern is breaking.

Why is the use of constructors discouraged when creating prototypes?

Quick background: In JavaScript, the constructor function for each object type has a prototype property. The prototype refers to an object that each constructed object uses as the next step up in its prototype chain. When you want one type to inherent from another type, you can set the prototype of the child type to a new instance of the parent type.

Why is the use of constructors discouraged when creating prototypes?

Quick background: In JavaScript, the constructor function for each object type has a prototype property. The prototype refers to an object that each constructed object uses as the next step up in its prototype chain. When you want one type to inherent from another type, you can set the prototype of the child type to a new instance of the parent type.

Initializing derived classes in the same way

I have a class Base that has several children, say A, B, C. For testing purposes I’d like to mock those derived classes by deriving from them. So MockA derives from A, MockB derives from B and so on.