| All visible objects, man, are but as pasteboard masks...strike, strike through the mask! - Herman Melville |
Object-Oriented DesignLecture notes, September 1999 Jeffrey Nickerson |
|
Course Administration Objects
Precepts are the fundamental units of experience,... observables are the fundamental units of natural systems - Rosen
(1985) 47 The synthesis of form is the crucial step of design. It is when alternative forms are generated. Later, the forms are paired down, analyzed in more depth, and finally one or a couple are chosen for implementation. Experienced good designers can generate more alternatives, and quickly assess them against a number of criteria, including cost. |
Every design is the expression of a possible future state.. - M. Nadin Introduction
Aristotle found four causes for everything. The fourth one he describes as the final cause - in essence, the purpose. Design is the process of creating things that serve a purpose. We work from the future backwards. Our method is one of generation, refinement, and problem solving, but really we are preparing ourselves for insight.
SystemsSystems have an incredibly vague definition, yet we understand what they are. Rosen (Life Itself, p42) describes it this way:
So the thing to be clear on is that systems are both living things and mechanical things, large complicated things and very simple things. They can usually best be thought of as a collection of interacting parts. An animal. A cell. And also things more amorphous. A weather system. A society. And the mechanical things we use. A car. An engine system. A computer system.
AnalysisRosen makes the strong distinction between natural systems and formal systems. Real systems in the external world are natural systems. So even mechanical things are natural systems. Mathematical constructs are formal systems. We sometimes operate on formal systems in the hopes of predicting what the natural system will do. So here is a diagram illustrating Rosen's idea:
The diagram looks the same - we have flipped Formal and Natural, and changed the labels on the arrows:
DesignSynthesis of form is usually taught to architects and engineers in the following way. They are given a design problem, and asked to generate several alternative solutions on paper. They are critiqued, and eventually asked to build something. In an architecture class, they may only be asked to build a scale model. In this class you will be asked to build a program. After you have learned to design. Part of the reason to create a model is that the model is usually easier to manipulate than the system it emulates. So a drawing of a house is easier to change than a house. A sketch of an object model is easier to change than 100,000 lines of software code. Designers get good at manipulating models and coming up with alternative ones. In the software world there are often phases of modeling, so that the overall process looks like this: |
![]() |
|
| Standard software methodologies usually gloss over the most important step - the generation of
alternatives, first at the business level, and then at the technical level. Theories come and go, the frog stays - Francois Jacob, cited in Nadin. Dahl, Myhrhaug, and Nygaard invented Simula in 1967 |
So the creation of a new piece of software may start with the analysis of a manual process, resulting in a model of the way things are currently done. Now we are in the world of formal models, and we manipulate the model, adding, deleting, substituting, until we have generated a few alternative more desirable models, the To Be models. We pick one of these models, which are still very much at the business level, and then generate a number of alternatives for implementing the model. We pick one of these designs, and build the piece of software.
ErrorsComputer systems often mess up. We usually call the problems bugs. These are differences between the model we have in our mind of the way the system should work and the realization. Now the question is where did something go wrong. And it can be anywhere in the diagram. Sometimes what we expected never got put down on paper. Or what we wanted was in conflict with another requirement. Or the implementation does not meet the specification. When an operating system crashes, we know that the implementation is not meeting the spec. And in the case of operating systems it is the shear size of the implementation that prevents all the differences from being removed. Problems discovered later are much more expensive to fix. But problems in a model take more imagination to see than problems in a malfunctioning program. AbstractionAn observation procedure applied to a natural system, generates an abstraction. You are measuring one thing - other qualities are ignored. SubsystemA subsystem is a part of a natural system which a small set of observation procedures let us see.
"The extraction and characterization of subsystems in terms of individual observables, and the employment of such characterizations to encode particular interactions, is the essence of system analysis." Rosen, (1985) 216
Algebraic SystemsAn algebraic system is a set on which we have an equivalence relation, to be able to tell if elements are the same, and some binary operations associated with it. Often there is an identity element. Along with operations and their corresponding inverses. So we have sets, and operations.
In theoretical terms, Goguen is writer who best models object-oriented approaches - he describes hidden algebras, that include visible sorts (types) to represent data values, and hidden sorts, for internal states. The object has a signature. A signature is a set of types and a set of operators, each with a given input and output type. An algebra is a signature with a function taking types to sets and another taking operators to functions. StateProbably the modern concept of states, especially as they relate to objects, comes from Sir Isaac. In Principia, Newton describes particle systems. If you know the displacement and momenta of the particles at an instant of time you can describe the entire state of the system. And if you have forces together with initial values of the state variables you can determine the state variables, and every other systems quantity, for all time. "An impressed force is an action exerted upon a body, in order to change its state, either of reset, or of uniform motion in a right line" Newton, p2. Newton's first Law of Motion
ObjectsIn order to get the idea of objects, think of an appliance - let's take a CD player. It has states, constituted by these attributes:
It has public outside operations:
It also has a set of invisible operations that only the engineers know about:
The interface for playing a CD, a video, a DVD is becoming standard - you can imagine that as designers, you just take for granted you will have buttons with certain labels indicating fast forward, pause, stop, rewind. This is what the interface convention of UML (and Java) can be used for: define a standard interface, and worry about how to implement it later. As a user, you only have to learn the interface once, and it will work on many different objects. OO languagesThe first OO language came from a set of Norwegians who wanted to build a simulation language. The language, they thought, would help us understand the world better. It was named Simula. And it was really used initially to try to simulate societal types of issues. Queuing theory was a big influence on the language - so the language was good at doing things like mimicking the wait at a bank for the next teller. Almost all the good object ideas go back to 1967. Smalltalk added a very important idea - that a graphic user interface is made up of sets of objects. We send messages to these objects by manipulating them with a mouse and a keyboard. C++ drew on Simula, and Java combined ideas from all the previous OO languages. |
| . UML text: Peter Coad et al, Java Design, 2nd Edition, Yourdon Press, 1999 Different types of UML diagrams: Sequence, Class, State, Activity, Collaboration, Use Case, Object, Package, Component, Deployment Here is a good UML reference site Scott Ambler's article on UML modeling of architecture is worth reading. Here is the Rational UML Quickreference - it is worth printing. And a UML primer Other recommended texts are those by Rumbaugh, Booch, and Jacobson, who are responsible for UML, as well as all texts by Coad. |
Visualizing Object DesignsEven though OO started in the 60s, it wasn't until the late 80s that standard ways of visualizing objects began appearing. But, to be fair, some other techniques, such as Entity-Relationship Modeling , are very close in concept to object modeling. In some ways, OO modeling is a co-opting of a variety of analytic diagrams that go way back. For more on visualization, see this chapter of my thesis. The Unified Modeling Language (UML)UML is a standard modeling convention, created to stop industry bickering and create a larger market for Computer-Aided Software Engineering tools based on Object-Oriented techniques. The current set of conventions in UML come from a number of different sources. There are at least 9 different diagram conventions that are part of the modeling language. And there are case tools such as Rational Rose that will allow you to create diagrams, move from diagrams to code, and then reverse-engineer back to diagrams. For the purpose of this course, UML is a tool - I am not going to teach every aspect of the different diagrams. I don't think all of them are useful. I do want you to be facile with the few diagram conventions I present here. By the way, the Coad book takes a similar approach, only using a subset of UML conventions.
Sequence DiagramsIn my mind, this is the most useful software diagram, period. Across the top we have objects. Between them we show messages. The extent of an objects control is shown by the vertical rectangle. There are two alternative conventions for showing returning messages - show them explicitly, or make them implicit in the way the message is passed back and forth.
You can see the two diagrams above are equivalent. Coad uses the later convention, in the following way:
The method name passes two parameters, the input and the output. In this case, an interface object is passing a name to a lookup object that will return a corresponding phone number.
Class DiagramsFor those of you who have been involved in database design, class diagrams will be very familiar. They look almost identical to entity-relationship diagrams. The major difference is that not only data attributes, but also operations are shown. This diagram is based on the one in Coad on page 25 - but I have added two classes, PlaneModel and Seat. |
![]() |
|
| "In the last resort, structure (i.e., order of parts) and function (order of processes) may
be the very same things." p27 Bertalanffy. patterns |
Notice that there is a relationship between sequence diagrams and class diagrams. Every arrow on sequence diagram that points toward an object is reflected as an operation of that object on this diagram. Notice that the associations, however, have nothing to do with the sequence diagram - just because an object calls another object doesn't mean there is a structural association between the two. Think of time and space, with the class diagram representing static relationships that define the structure of the domain. From the right level of class diagram, it is possible to generate code stubs. The CD in the back of the Java Design book contains a CASE program that will allow you to create a class diagram, and from it, generate Java. It will even work the other direction. The crucial decision the case tool will make is how to encode the association links of the diagram. For this it will work off the cardinality information that you can provide it. The way to keep cardinality straight is to think it through in two steps, from the perspective of each object. "If I am a reservation, how many seats do I associate with" which we have answered with a 1. "If I am a seat, how many reservations do I have associated with me" - which we have answered with a zero or 1. Now notice that we have an assumption here - we are somehow going to have to generate a new seat object for each scheduled flight.
There is another unusual feature of this diagram - the diamond shape shows aggregation, which can be read "part of". The seats are part of the flight. If the flight is canceled, the seats disappear.
The treatment of inheritance and its alternatives in Coad, chapter 2, is very good. In particular, it is useful to understand than the inheritance tree of a Java applet goes like this: Applet -> Panel -> Container -> Component -> Object. So when we create an applet, we can inherit from applet, which already has a large set of pre-defined methods. We don't have to bother to write special methods for resizing the window, unless there is something out of the ordinary we want to do. Design IssuesWhen do you go from analysis to design? When you stop being concerned with the present situation and start to motivate yourself for action. But the boundary is not so clear - your analysis has a motivation, which is usually to understand a present state so your future state will fulfill the implicit requirements of the current environment. A typical user requirement: "I want it to do everything it does now, but these additional thing, and a lot faster, without any of the current drawbacks, and I want the new system to be inexpensive, delivered soon, and be flawless".
|
Further reading
|
|
| Philosophy may be ignored but not escaped; and those who most ignore least escape - David Hawkins, cited in Rosen |
Course AdministrationLecture text: Peter Coad et al, Java Design, 2nd Edition, Yourdon Press, 1999. Reading Assignments:
Assignment for the second lecture
|
| Email to the lecturer: jeff@nickerson.to | |