Questions tagged [class-hierarchy]

Class hierarchy refers to a set of classes and their inter-relationships.

A classification of object types, denoting objects as the instantiations of classes (class is like a blueprint, the object is what is built from that blueprint) inter-relating the various classes by relationships such as "inherits", "extends", "is an abstraction of", "an interface definition".

http://en.wikipedia.org/wiki/Class_hierarchy

276 questions
6
votes
5 answers

Overloading with a class hierarchy - most derived not used

The problem I am trying to avoid code that looks like the following: If(object Is Man) Return Image("Man") ElseIf(object Is Woman) Return Image("Woman") Else Return Image("Unknown Object") I thought I could do this through method overloading,…
Lee
  • 1,591
  • 1
  • 14
  • 28
6
votes
1 answer

Spring(Java): Aspect is not triggered in non linear class hierarchy

When class hierarchy is not linear, aspect is not triggered when defined on base interface. The most interesting: when adding delegating implementation (see last code block) to the parent class of the implementation, the test becomes Green (Aspect…
Sergej Werfel
  • 1,335
  • 2
  • 14
  • 25
6
votes
4 answers

C# property not available in derived class

I'm not sure what's going on. I have the following base class: public class MyRow : IStringIndexable, System.Collections.IEnumerable, ICollection>, IEnumerable>, …
Sarah Vessels
  • 30,930
  • 33
  • 155
  • 222
6
votes
1 answer

Create inheritance graphs/trees for Django templates

Is there any tool out there that would take a directory with a Django application, scan it for templates and draw/print/list a hierarchy of inheritance between templates? Seeing which blocks are being overridden at every level would be an especially…
Tommalla
  • 297
  • 1
  • 2
  • 10
6
votes
2 answers

Spring JDBC RowMapper with Class Hierarchies

I wanted to know what the community considers the "best practices" in respect to mapping class hierarchies with Spring JDBC. We do not have the ability to use a full fledged ORM tool, however we are using the Spring JDBC to alleviate some of the…
jnt30
  • 1,367
  • 2
  • 15
  • 21
6
votes
3 answers

Is there any reason for an empty concrete method in an abstract class?

I was recently looking through some open source code PicketLink code. If you take a look at this class, you'll see a number of concrete methods in an abstract class that do nothing. Is there any purpose whatsoever for this? I thought about two…
josh-cain
  • 4,997
  • 7
  • 35
  • 55
5
votes
4 answers

Pharo/Squeak - How do I quickly browse the implementation of a given method in a given class?

Let's say I want to see how "copy" is implemented in the Dictionary class. Currently I use the system browser and manually traverse the inheritance hierarchy (bottom up) until I find the class that implements the given message. Is there a one-liner…
Janus Troelsen
  • 20,267
  • 14
  • 135
  • 196
5
votes
4 answers

Giant switch statement for constructors

I have a container which holds a bunch of pointers to a base class, and a function which takes some input and returns a class which is a subclass of the base class. Which subclass it returns depends on the input. Right now, I have a giant switch…
Seth Carnegie
  • 73,875
  • 22
  • 181
  • 249
5
votes
4 answers

Compile time tree structure

I want to retrieve values from a tree stored in another system. For example: GetValue("Vehicle.Car.Ford.Focus.Engine.Oil.Color") To avoid typing errors and invalid keys, I want to check the name at compile time by creating an object or class with…
Sjoerd
  • 74,049
  • 16
  • 131
  • 175
5
votes
2 answers

reinterpret_cast vector of pointers to vector of pointers to base class

Consider the following piece of code #include #include #include #include struct Base { int x; Base(int x) : x(x) {} }; struct Derived : public Base { int y, z; Derived(int x) : Base(x),…
Rafal
  • 91
  • 1
  • 7
5
votes
1 answer

PHP Class finds Class file but not Class in the file

I've defined an abstract superclass in one file and a subclass in another. I have required the super-classes file and the stack trace reports to find an include it. However, it then returns an error when it hits the 'extends' line: Fatal error:…
Daniel Bingham
  • 12,414
  • 18
  • 67
  • 93
5
votes
4 answers

c# implement interface method with parameter of subclass type

I have this desired class hierarchy: interface IClass { string print(IClass item); } class MyClass : IClass { // invalid interface implementation // parameter type should be IClass not MyClass string print(MyClass item) { return…
Angie
  • 319
  • 3
  • 12
5
votes
8 answers

Is there any relation between the class that implements interface and that interface?

Consider this class hierarchy: Book extends Goods Book implements Taxable As we know, there is a relationship between a subclass and its superclass (is-a). Q: Is there any relationship like "is-a" between Book and Taxable? GOOD Answers, but you…
Johanna
  • 27,036
  • 42
  • 89
  • 117
4
votes
4 answers

Calling child method, when cast to parent type in java

I am having problems with some course work i'm trying to finish off and any help would be appreciated! I have 3 types of accounts which extend an abstract type "Account".. [CurrentAccount, StaffAccount and MortgageAccount]. I am trying to read in…
krex
  • 345
  • 3
  • 8
  • 21
4
votes
1 answer

Define a hierarchy of model classes in CakePHP

By default CakePHP has a AppModel class and every model of an application inherits from it. A common design pattern to share logic between models is to create a behavior and configure a model to $actAs that behavior. But what if I wanted to…
elitalon
  • 9,191
  • 10
  • 50
  • 86
1 2
3
18 19