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
3
votes
3 answers

Table per Concrete Class Hierarchy in Hibernate

I have the following Hibernate Mapping, which has to be mapped using the Table per Concrete Class Hierarchy:
melculetz
  • 1,961
  • 8
  • 38
  • 51
3
votes
1 answer

Traits vs. abstract classes for code reuse

While working on a project i stumbled across a question relating to the proper way of choosing the correct form of code reuse in terms of traits vs. abstract base classes. I came across the point where i have multiple abstract base classes but can…
Jay
  • 1,035
  • 2
  • 11
  • 22
3
votes
6 answers

Use of generics in a final method that returns a value of the same type of its object

Consider the following immutable classes: A B extends A C extends B D extends C ... Class A has a method called process that gets a parameter of type A, and then returns a value of the type of the calling object: public class A { public final…
Marcelo Glasberg
  • 29,013
  • 23
  • 109
  • 133
3
votes
2 answers

In this Java class hierarchy, how to use Generics so that type casts are unnecessary?

Suppose I have 2 classes called RealNumber and IntNumber, and a method called plus: public class RealNumber { public S plus(S realNumber) { ... } } public class IntNumber extends…
Marcelo Glasberg
  • 29,013
  • 23
  • 109
  • 133
3
votes
1 answer

How to correct implement ICloneable in a tree hierarchy rooted by an abstract class?

Given a tree hierarchy, suppose it is the following: abstract class Person : ICloneable ... sealed class Student : Person ... I want to implement the ICloneable interface. In the Student.Clone method I wish to do something like: { Student…
mdarefull
  • 829
  • 2
  • 14
  • 24
3
votes
1 answer

Scala package private with duplicate name in package hierarchy

So I understand that in Scala, you can define something private within the scope of a specific package by adding the modifier private[packagename] where packagename is (obviously) the name of the package that you wish the reference to be private…
childofsoong
  • 1,918
  • 16
  • 23
3
votes
2 answers

How to print current class name with logback?

The following config
Suzan Cioc
  • 29,281
  • 63
  • 213
  • 385
3
votes
5 answers

How to implement or emulate an "abstract" OCUnit test class?

I have a number of Objective-C classes organized in an inheritance hierarchy. They all share a common parent which implements all the behaviors shared among the children. Each child class defines a few methods that make it work, and the parent class…
Quinn Taylor
  • 44,553
  • 16
  • 113
  • 131
3
votes
3 answers

Java - Class Hierarchy

I'm relatively new to programming and for one of my classes I have to create a class hierarchy for the following things: Country, State, County, City, Boundary, and River. How would I do this? I think I understand that I cannot use extends because…
3
votes
2 answers

Best Way to Organize PHP Class Hierarchy

I've got a somewhat primitive framework I've been using for most of my projects, but a general design issue came to mind that I haven't been able to work out yet. For a given application, should I separate the application-specific class structure…
Wilco
  • 32,754
  • 49
  • 128
  • 160
3
votes
2 answers

What design should I use so a class can query one of it's ancestors?

I'm creating an object hierarchy that is representing a table that is draw on a control. My hierarchy looks like this : Table has multiple pages Page has multiple lines Line has multiple cells Cell has multiple glyph I want to have an option (a…
Mathieu Pagé
  • 10,764
  • 13
  • 48
  • 71
3
votes
5 answers

Design pattern to use

I want to make the program with the following classes: Class Player, which stores some information about players with get/set functions. Player can be as AttackPlayer, which will have own data with get/set functions. Also Player can be as…
maximus
  • 4,201
  • 15
  • 64
  • 117
3
votes
1 answer

Directory structure - file and folder classes should know each other?

I encountered a problem with two classes knowing each other when I was trying to create a directory structure similar to this: Here's my Base class which includes the common elements of File and Folder. Notice that I've left out getters and…
user2032433
2
votes
6 answers

Where to find Java API Class diagrams?

Is there a site where we can find JAVA API class diagrams. It helps to be able to see the class hierarchy (example Exception class hierarchy) in a visual manner. Thanks.
dumptoday
  • 197
  • 3
  • 6
2
votes
1 answer

Programmatically push down "safe" methods in Smalltalk

I want to collect which methods can be safely pushed down from a superclass to a subclass, specifically, when you have only one subclass and there is no reason to maintain the method in the superclass. It could be a matter of dinamically discover…
user869097
  • 1,362
  • 8
  • 16