Composition and a Simple Container Class

Composition and a Simple Container Class

For access to this article, please select a purchase option:

Buy chapter PDF
(plus tax if applicable)
Buy Knowledge Pack
10 chapters for £75.00
(plus taxes if applicable)

IET members benefit from discounts to all IET publications and free access to E&T Magazine. If you are an IET member, log in to your account and the discounts will automatically be applied.

Learn more about IET membership 

Recommend Title Publication to library

You must fill out fields marked with: *

Librarian details
Your details
Why are you recommending this title?
Select reason:
A Guide to MATLAB® Object-Oriented Programming — Recommend this title to your library

Thank you

Your recommendation has been sent to your librarian.

As a further demonstration of composition, there is an initial foray into designing and implementing a general container class. A general container is different from an array because it can hold different types. A general container is different from a cell array because all objects must descend from the same parent. For example, a general cShape container can hold both cStar and cDiamond objects because they both use cShape as a parent. A container is also different from a cell array because a container has a structure-like interface. The interface makes a container behave a lot like an object array. Rather than looping over each element in the container, clients can use vector syntax. Often the loop still exists; however, it is now hidden behind the container's interface. Developing a set of standard containers compatible with the general computer-engineering literature or with National Institute of Standards (NISI) definitions would be an enormous undertaking. The primary goal of the paper is to demonstrate one potential use of composition. A secondary goal is to produce a container that might be useful as is, or at least produce a container that can be easily improved.

Chapter Contents:

  • 19.1 Building Containers
  • 19.2 Container Implementation
  • 19.2.1 The Standard Framework and the Group of Eight
  • Container Modifications to fieldnames
  • Container Modifications to subsref
  • Container Modifications to subsasgn
  • Container Modifications to get
  • Container Modifications to set
  • 19.2.2 Tailoring Built-in Behavior
  • Container-Tailored end
  • Container-Tailored cat, horzcat, vertcat
  • Container-Tailored length, ndims, reshape, and size
  • 19.2.3 cShapeArray and numel
  • Container-Tailored num2cell and mat2cell
  • 19.2.4 Container Functions That Are Specific to cShape Objects
  • cShapeArray times and mtimes
  • cShapeArray draw
  • cShapeArray reset
  • 19.3 Test Drive
  • 19.4 Summary
  • 19.5 Independent Investigations

Inspec keywords: object-oriented programming

Other keywords: NISI definition; Matlab; cStar container; container composition; vector syntax; object array; cDiamond container; cShape container; container class; cell array; National Institute of Standards

Subjects: Object-oriented programming

Preview this chapter:
Zoom in

Composition and a Simple Container Class, Page 1 of 2

| /docserver/preview/fulltext/books/pc/sbpc001e/SBPC001E_ch19-1.gif /docserver/preview/fulltext/books/pc/sbpc001e/SBPC001E_ch19-2.gif

Related content

This is a required field
Please enter a valid email address