Thursday, July 1, 2010

Group of Eight in Matlab

MATLAB object-oriented rules dictate only one required function for each class. In practice, there are eight functions so fundamental to MATLAB object-oriented programming that each warrants its own chapter. Apart from each other, any one from this group of eight would be easy to describe, design, and code. Toy classes rarely use more than two or three of the eight, making their design easy. We are not interested in toy classes. In industrial-strength classes, the functions comprising this so-called group of eight always occur together, and each relies on functionality contained in the other members. In Chapter 1, we discussed dependency and coupling and concluded that such reliance requires careful attention to detail. Care is doubly important for the group of eight because these functions implement the most important part of any object, its interface. As you read along and consider the examples, keep the fact of coupling in mind. Sometimes it forces design decisions that become apparent only after the coupling partner is described, designed, and implemented.

As we will soon see, the notion of an interface goes hand in hand with the object-oriented concept of encapsulation. This first major section focuses on object-oriented encapsulation and develops an effective interface strategy. By the end of this section, the advantages of encapsulation along with the access rules enforced by MATLAB should be clear. Every function in the group of eight contributes to encapsulation. If you are wondering about the names of the group-of-eight functions, they are listed below. There are chapters in this section devoted to each member.

Functions belonging to the group of eight are :
  • constructor
  • subsref.m
  • subsasgn.m
  • display.m
  • struct.m
  • fieldnames.m
  • get.m
  • set.m
The required elements are the best place to begin. First, there are not many; and, second, the
required elements should exist in every class we write. After we cover the required elements, we will develop a set of optional elements that allow object-oriented variables to attain a status equal to built-in types. Without these optional elements, object-oriented code is difficult to use and maintain. After the optional elements, we examine strategies for atypical situations. This section covers all of the required and many of the optional object-oriented coding elements.

Andy H. Register


Digg Google Bookmarks reddit Mixx StumbleUpon Technorati Yahoo! Buzz DesignFloat Delicious BlinkList Furl

0 comments: on "Group of Eight in Matlab"

Post a Comment