RationalDB 





User Defined Data Types  «Prev  Next»

Lesson 1

Introduction to User Defined Data Types

Traditional programming languages provide a small set of standard data types such as integer, floating-point number, and string. But these types do not fully represent real-world objects. For instance, an employee is not just an integer, a floating-point number, or a string. An employee does have a name that is a string, a salary that is a floating-point number, and an ID that is an integer.
Classes combine primitive data types such as integer, floating-point number, and string into new programmer-defined data types such as employee. Specific instances of a class (for example, name: Joe Smith, salary: $36,500.75, ID: 834) are objects.
In this module, you will learn:
  1. How classes allow programmers to create new data types
  2. That classes have attributes that define the state of an object in the class
  3. That objects are specific instances of classes with particular values for the classes's attributes
  4. How to read and draw class diagrams
  5. How to read and draw object diagrams

Dangers of Multiple Inheritance

Some languages (such as C++) allow a class to extend more than one other class. This capability is known as "multiple inheritance." The reason that Java's creators chose not to allow multiple inheritance is that it can become complicated. In a nutshell, the problem is that if a class extended two other classes, and both superclasses had, say, a doStuff() method, which version of doStuff() would the subclass inherit?
This issue can lead to a scenario known as the Deadly Diamond of Death, because of the shape of the class diagram that can be created in a multiple inheritance design. The diamond is formed when classes B and C both extend A, and both B and C inherit a method from A. If class D extends both B and C, and both B and C have overridden the method in A, class D has, in theory, inherited two different implementations of the same method. Drawn as a class diagram, the shape of the four classes looks like a diamond.