CSE2305/CSC2050 - Object-Oriented Software Engineering
Week 9
Topic 17: The Booch Notation
Synopsis
- A way of capturing the relationships in an
OO design.
- A way of thinking about the
relationships in an OO design.
- But not (by itself) equivalent to an OO
design
- ...also need text to explain the reasons for
the structure, the purpose of various components,
and the general nature of the interactions
- You already know how to represent classes¤ in Booch
notation
- They are "broken clouds"...
- ...labelled with the class¤ name...
- ...and possibly with its attributes and operations
- That corresponds to the C++ code:
class Vehicle
{
public:
Vehicle(void);
virtual bool Register(string regnum);
string GetRego(void);
private:
string myRegNum;
};
- You also already know how to represent inheritance
- The arrow goes from the derived class¤¤ back to
the base class¤¤
- That corresponds to the C++ code:
class Vehicle
{
public:
Vehicle(void);
virtual bool Register(string regnum);
string GetRego(void);
private:
string myRegNum;
};
class Car : public Vehicle
{
public:
Car(string make, string model);
virtual bool Register(string regnum);
string GetDescription(void);
private:
string myMake;
string myModel;
};
- There are several other possible class¤ relationships
- The aggregation¤ relationship is the most common and
represents the relationship where one class¤ has
members¤ belonging to some other class¤.
class StudRec
{
public:
StudRec(int ID, string name, double mark);
int GetID(void);
string GetName(void);
double GetMark(void);
private:
int myID;
string myName;
double myMark;
};
- The aggregation¤ relationship ("has") is represented
by a line with a black disc at the "owner" object
- There are two "sub-types" of aggregation¤: by value and by
reference¤.
- If one class¤ aggregates another by value it actually has
a member¤ of that other class¤:
class StudRec
{
public:
StudRec(int ID, string name, double mark);
int GetID(void);
string GetName(void);
double GetMark(void);
private:
int myID;
string myName;
double myMark;
};
- This is represented by using a solid box at the other end of
the "has" link
- On the other hand, a class¤ may store a pointer or
reference¤ to some other class¤:
class StudRec
{
public:
StudRec(int ID, string name, double mark);
int GetID(void);
string GetName(void);
double GetMark(void);
private:
int* myIDPtr;
string* myNamePtr;
double* myMarkPtr;
};
- This is called agregregation by reference¤ and is represented
by a hollow box:
- The client/server relationship ("uses") is represented
by a line with a circle at the "owner" object
class StudRec
{
public:
StudRec(int ID, string name, double mark);
int GetID(void);
string GetName(void);
double GetMark(void);
void PrintMe(ostream& os);
void ReadMe(istream& is);
private:
int myID;
string myName;
double myMark;
};
- The nesting relationship is represented by nesting clouds
- For example, the
BSTree
class¤:
class BSTree
{
private:
class Node
{
public:
int myValue;
Node* myLeft;
Node* myRight;
Node(void);
}
public:
// ETC...
};
- Also note that we could indicate the "reflexive"
relationship of the
Node
class¤ to itself (i.e.
the fact that each Node
contains pointers to
other Node
s)
- Templates (e.g.
List<Type>
) are represented as "broken clouds"
with "broken boxes" for the various template
parameters
template <class TYPE>
class ListOf
{
public:
bool First(void);
bool Next(void);
TYPE GetCurrent(void);
bool InsertCurrent(const TYPE& newelem);
bool DeleteCurrent(void);
private:
TYPE* myArray;
int mySize;
int myNextFree;
};
- Actual classes¤ specialized from a template (e.g.
List<string>
)
are represented like template clouds, except the box is
now solid.
template <>
class ListOf<bool>
{
public:
bool First(void);
bool Next(void);
TYPE GetCurrent(void);
bool InsertCurrent(const TYPE& newelem);
bool DeleteCurrent(void);
private:
long* myPackedArray;
};
- Class¤ utilities are non-OO components of
a program (like the function
main()
or the
math.h
library).
- Class¤ utilities are represented by a class¤ cloud
with a shadow
- Of course, in a real design (even a simple one)
you need to use most of these notations in the
same diagram:
- In order to make clear the way in which a design
is structured it is not enough just to show the
class¤ relationships
- It is often also important to show the actual
objects that will be instantiated
- In the Booch notation, objects are represented
as "unbroken clouds":
- One way of describing the relationships between
objects in a system is to represent each and
then draw labelled arrows indicating who calls
whom
- This is called an Object Diagram:
- Another approach emphasizes the time-line of calls
- It is called an Interaction Diagram:
- Note that data is assumed to flow back up the
arrows implicitly
- Can also "thicken" the object life-lines to
indicate which object(s) are the focus of
control at any point:
- Booch also provides notation for many other
aspects of system design, including...
- ...class¤ categories (higher level groups of
classes¤)
- ...metaclasses¤ (classes¤ which represent the
type of other classes¤ - not a C++ concept)
- ...state¤ transition diagrams (yet another way
of capturing program flow of control)
- ...synchronization of method calls in threaded
(parallel) systems
- ...modules (code level groupings of classes¤
- corresponds to namespaces and files in C++)
- ...processors and devices (harware level view
of the system)
- ...annotations and adornments (convey extra
information textually)
Booch, G., "Object-oriented Analysis and Design with Applications",
Second Edition, Benjamin Cummings, 1994 (in particular: Chapter 5).
This material is part of the CSE2305/CSC2050 - Object-Oriented Software Engineering course.
Copyright © Damian Conway, 1998. All rights reserved.
Last updated: Tue Jul 6 11:33:55 1999