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
2
votes
1 answer

How to do structural typing in scala that ALSO only accepts subclasses?

Instead of describing the problem in words, let me just show you a Scala Interpreter session that shows what I want to do. scala> class A extends Parent{ | def name = "Alex" | } defined class A scala> class B extends…
2
votes
1 answer

Nested types in Swift

I have UICollectionView with cells: Image, Text, or Image+Text. class ParentCell: UICollectionViewCell { class ImageCell: ParentCell { class TextCell: ImageCell { } } class TextCell: ParentCell { } } func…
111
  • 31
  • 2
2
votes
3 answers

PHP tricky problem

I have the following class structure: class Parent { public function process($action) { // i.e. processCreateMyEntity $this->{'process' . $action}; } } class Child extends Parent { protected function…
Vadim Samokhin
  • 3,378
  • 4
  • 40
  • 68
2
votes
2 answers

Codeigniter declaring class level variable in CI_Model class

I am new to PHP and Codeigniter, and I am declaring a class level variable which I wanted to access in model class. I'm getting an error that the variable is not defined. Here is my code: class Country_model extends CI_Model{ protected $table =…
Mike
  • 118
  • 1
  • 3
  • 11
2
votes
1 answer

Count number of classes and class hierarchies in a Python package

I have a directory with many subdirectories with Python source code which correspond to a Python package. I want to count how many classes and root classes (top of hierarchies) are contained in these directories/package. Any easy way to do this?
Ray Doyle
  • 829
  • 1
  • 6
  • 8
2
votes
0 answers

Considering Java types (like Collection) as subtypes of Kotlin types (like MutableCollection)

Kotlin somehow considers java.util.Collection as extending kotlin.collections.MutableCollection. Is there any way for this same functionality to be used by code written outside the Kotlin standard libraries? e.g., I want to create my own Kotlin…
XDR
  • 4,070
  • 3
  • 30
  • 54
2
votes
1 answer

Scala - root of covariant type hierarchy

The following Scala class: class Foo[+T <: Bar] extends FooBase ... effectively defines a type hierarchy which has Foo[Bar] as its root - i.e. any valid Foo[X] will be assignable to a Foo[Bar] value or variable: val v1: Foo[Bar] = new…
Learner
  • 1,215
  • 1
  • 11
  • 26
2
votes
2 answers

Child class calls a method of the parent class

In objective-C I want to have a child class call or invoke a parent's method. As in the parent has allocated the child and the child does something that would invoke a parent method. like so: //in the parent class childObject *newChild =…
Danegraphics
  • 447
  • 1
  • 7
  • 21
2
votes
0 answers

Good practices for unit-testing class hierarchies

What are common/widely accepted practices for unit testing class hierarchies? I've tried to look for different questions that are related to this problem, but couldn't find comprehensive one. Let's suppose there is a hierarchy under test. class…
libxelar.so
  • 473
  • 4
  • 16
2
votes
1 answer

How to define Angular class hierarchy with service dependencies

My head is going around in circles on this one. I want to create classes to represent data returned from the back end in Angular (not AngularJS). I have two top level classes Variation and Reallocation. Both are types of base class Adjustment.…
2
votes
2 answers

Useful publish-subscribe semantics

I'm looking for Wikpedia-style references to designs and implementations of lightweight publish-subscribe mechanisms that actually work. I will update the question according to the answers and comments, and to my own research. I researched my…
Apalala
  • 9,017
  • 3
  • 30
  • 48
2
votes
1 answer

Class vs Object hierarchies

How do you explain class hierarchies. I think my google power has gone down because when i searched for 'Class hierarchies' as the term i got a few examples of how classes are organized and the inheritance relationship between them. Is that all…
Asif
  • 1,288
  • 1
  • 16
  • 27
2
votes
1 answer

An idiom for a particular refactoring in c++

I asked this question : Best Way to Refactor Class Hierarchy in such a bad way that I was logically forced to accept the perfectly correct answer. My problem is the following : I have a class CGrandMother having a public method virtual bool…
Olórin
  • 3,367
  • 2
  • 22
  • 42
2
votes
3 answers

Learning interfaces and hierarchies, where to place certain variables and methods?

So as part of a car rental system I need to write classes to represent large and small cars, the difference between these being that they have different size tanks and consume fuel at different rates. Currently my approach is to have an interface,…
transiti0nary
  • 493
  • 6
  • 25
2
votes
3 answers

Transform an object to its subclass in Java

This is not a regular question, please listen to my explain. I have an object of class Animal. How can I transform it to its subclass Cat? Like this: Animal a = new Animal(); Cat c = (Cat) a; Of course, I know It's not possible casting directly…
jinge
  • 785
  • 1
  • 7
  • 20