A Guide to MATLAB Object-Oriented Programming

Part 2: Building a Hierarchy

CHAPTER LIST

Chapter 11: Constructor Redux
Chapter 12: Constructing Simple Hierarchies with Inheritance
Chapter 13: Object Arrays with Inheritance
Chapter 14: Child-Class Members
Chapter 15: Constructing Simple Hierarchies with Composition
Chapter 16: General Assignment and Mutator Helper Functions
Chapter 17: Class Wizard
Chapter 18: Class Wizard Versions of the Shape Hierarchy

PART OVERVIEW

This section focuses on building hierarchies because objects and hierarchies go hand in hand. For example, a hierarchy of shapes might include rectangles, stars, and circles. A hierarchical implementation allows one class to build on functions defined in another class. An object-oriented hierarchy can do this without a lot of rework. Throughout the first section, we simplified much of our code by coercing MATLAB into doing a lot of the work. In a small way, all classes are hierarchical because they build on the built-in types. MATLAB is always at the top of the hierarchy. A deeper hierarchy of classes follows the same philosophy. The lower-level class, sometimes called the child, tries to coerce a higher-level class, the parent, into doing as much as possible. This is the way of a hierarchy: always try to force the next higher level into doing all the work.

When a child class coerces a parent to perform an operation, the child is said to inherit that particular function from the parent. There are different flavors of inheritance. Differences depend on how control passes to the parent. A parent child relationship is what we normally think...

UNLIMITED FREE
ACCESS
TO THE WORLD'S BEST IDEAS

SUBMIT
Already a GlobalSpec user? Log in.

This is embarrasing...

An error occurred while processing the form. Please try again in a few minutes.

Customize Your GlobalSpec Experience

Category: Integrated Development Environment (IDE)
Finish!
Privacy Policy

This is embarrasing...

An error occurred while processing the form. Please try again in a few minutes.