This preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
Unformatted text preview: 7 The static structure: classes E xamining the software engineering background of our discussion, you have seen the reasons for demanding a better approach to modular design: reusability and extendibility. You have realized the limitations of traditional approaches: centralized architectures limiting flexibility. You have discovered the theory behind the objectoriented approach: abstract data types. You have heard enough about the problems. On to the solution! This chapter and the others in part C introduce the fundamental techniques of object oriented analysis, design and programming. As we go along, we will develop the necessary notation. Our first task is to examine the basic building blocks: classes. 7.1 OBJECTS ARE NOT THE SUBJECT What is the central concept of object technology? Think twice before you answer “object”. Objects are useful, but they are not new. Ever since Cobol has had structures; ever since Pascal has had records; ever since the first C programmer wrote the first C structure definition, humanity has had objects. Objects remain important to describe the execution of an OO system. But the basic notion, from which everything in object technology derives, is class , previewed in the preceding chapter. Here again is the definition: Abstract data types are a mathematical notion, suitable for the specification stage (also called analysis). Because it introduces implementations, partial or total, the notion of class establishes the necessary link with software construction — design and implementation. Remember that a class is said to be effective if the implementation is total, deferred otherwise. Definition: class A class is an abstract data type equipped with a possibly partial implementation. Objects are stud ied in detail in the next chapter . THE STATIC STRUCTURE: CLASSES § 7.2 166 Like an ADT, a class is a type: it describes a set of possible data structures, called the instances of the class. Abstract data types too have instances; the difference is that an instance of an ADT is a purely mathematical element (a member of some mathematical set), whereas an instance of a class is a data structure that may be represented in the memory of a computer and manipulated by a software system. For example if we have defined a class STACK by taking the ADT specification of the previous chapter and adding adequate representation information, the instances of that class will be data structures representing individual stacks. Another example, developed in the rest of this chapter, is a class POINT modeling the notion of point in a two dimensional space, under some appropriate representation; an instance of that class is a data structure representing a point. Under one of the representations studied below, the cartesian representation, each instance of POINT is a record with two fields representing the horizontal and vertical coordinates, x and y , of a point....
View
Full
Document
This note was uploaded on 10/02/2009 for the course CS 4376 taught by Professor Christeansan during the Spring '09 term at Dallas Colleges.
 Spring '09
 christeansan

Click to edit the document details