The purpose of this tutorial is to present "step
by step" instructions on how to model, program, and script
an object-oriented system. This tutorial uses a scripting CASE
tool to create object-oriented diagrams, fill-in specification
forms, generate C++ with code generation scripts, and to create
code generation scripts. A script is a program (set of
script statements) that prints out text statements for reports
and code. This tutorial presents the Object Modeling Technique
(OMT) presented in Object-Oriented Modeling and Design
by James Rumbaugh, Michael Blaha, William Premerlani, Frederick
Eddy, and William Lorensen. All specifications are based upon
Object-Oriented Design with Applications by Grady
Booch. This tutorial primarily uses the With Class CASE tool.
This tutorial presents a few specification items and script variables
in addition to those provided in the With Class CASE tool fill-in
specification forms.
To create the various diagrams, text specifications, and C++ code in this tutorial, you should have access the following Windows programs:
O-O modeling means to create object-oriented diagrams,
text specifications, and code to describe a system, subsystems,
and classes. It is to examine a problem from different points
of view and to create a software solution to the problem. Just
as an automotive design engineer creates drawings, clay models,
and text specifications of a new car, we create diagrams, text
specifications, and code to describe a new software system. The
ultimate aim is to create a new software system (computer program)
for the problem that has excellent S/W quality factors, e.g. correct,
reliable, and modifiable.
Inputs Process of O-O Modeling Outputs
System Object Model Diagrams
Requirements Dynamic Model Text Specifications
Functional Model Code & Prototypes
There are two primary objectives of this tutorial.
The first objective is to present how to model and prototype in
C++ a simple class using a CASE tool. One example will be provided:
a car that a user can start, operate, stop, add a passenger, remove
a passenger, make a cellular phone call, and receive a cellular
phone call.
The second objective is to present how to model and
prototype a simple system in C++. One example will be provided:
a TV controller to manipulate the volume and channel settings.
All examples will use a variety of documentation products, e.g.
diagrams, text specifications, and code.
In O-O modeling we will follow a progression as shown
below:
1st - State the objective or problem, e.g. a transportation system.
2nd - Create O-O diagrams, e.g. class diagrams.
3rd - Create O-O text specifications, e.g. class specification.
4th - Find or update the appropriate report and code generation scripts
5th - Generate code with the CASE tool.
6th - Update and execute the code for an executable prototype, e.g. C++.
7th - Reverse engineer the code to update diagrams
and specifications.
The basic inputs and outputs in O-O modeling are
shown below. We'll start with a problem such as "model a
car'. We'll use an O-O methodology to describe the car from an
object (classes and relationships), dynamic (messages and states),
and functional (data computation) points of view. We'll work to
achieve S/W quality factors such as correctness and reliability.
We'll use various Windows tools such as CASE (Computer Aided S/W
Engineering) and C++ development environments. We'll produce various
O-O diagrams, text specifications, CASE tool generated C++ code,
and finally updated C++ code for an executable prototype.
Objective O-O S/W Quality Factors Report Windows Tools -
or Problem Methodology - & Techniques and Code CASE, GUI,
Object, Dynamic, Generation C++ Environment,
& Functional Models Scripts Libraries
O-O Diagrams - O-O Specifications - Generated Updated Code
Class, State Class, Attribute, Code for Executable
Operation Prototypes
O-O modeling provides an effective framework to analyze,
design, and prototype systems. It is well suited for today's O-O
languages such as C++, Objective-C, Eiffel, Ada 9X, Object Pascal,
Delphi, Object COBOL, etc. It is well suited for emerging O-O
data base management systems. The traditional functional decomposition
software methodology was useful for procedural languages such
as C, FORTRAN, and COBOL. However, O-O modeling provides substantial
advantages over the functional decomposition methodology. O-O
modeling provides the following:
O-O modeling has many benefits. The following are several quotations on the benefits of O-O modeling. Boehm-Davis and Ross stated "The completeness, complexity, and design time data would seem to suggest that there is an advantage to generating program solutions using...object-oriented methods. The object-oriented method seemed to produce better solutions for [a problem] which involved real-time processing" [Boehm-Davis-84]. Borgida stated "The chief advantage of object-oriented frameworks is that they make possible a direct and natural correspondence between the world and its model" [Borgida-85]. Booch stated "In general, understandability and maintainability are enhanced due to the fact that objects and their related operations are localized" [Booch-86]. Bernard stated "Concepts such as module coupling and module cohesion are addressed virtually automatically by OOD. Specifically, OOD done correctly, will almost always result in modules which are highly cohesive (i.e. perform a single specific function) and loosely coupled (i.e. the interconnection between modules will be fairly weak)" [Berard-86]. Winblad, Edwards, and King stated "Ask don't touch...Design applications by snapping together the necessary objects" [Winblad-90].
There are three major documentation products for O-O modeling: diagrams, text specifications, and code as described below:
The major O-O diagrams to be created using a CASE tool are the system diagram, class diagram, event flow diagram, and object interaction diagram. A major diagram to be created with a CASE tools is the state diagram. System drawings and interface drawings will be created using a CASE tool or a Windows drawing tool. These diagrams may also be created using any CASE tool or full-featured drawing tool. Drawing tools like Shapeware's Visio may be used to create diagrams.
There are many text forms used in O-O modeling. These
include system requirements statements, data dictionaries, class
specifications, event lists, and interaction scenarios (messages).
The CASE tool or a Windows word processor will be used to create
text specifications.
Source code in C++ will be initially generated using a CASE tool. Then this generated code will be compiled using Borland C++ or Visual C++. Next messages and transformations will be added to the source code for a full executable C++ prototype.
There are four major windows tools for O-O modeling: windows word processor for text specifications and simple diagrams; CASE tool for O-O diagrams, text specifications, and C++ code generation; GUI interface builder for GUI prototypes and code generation; and C++ development environment. In this tutorial the following windows tools are used:
The windows word processor is important to create text specifications and simple drawings. A windows word processor has both text creation and simple drawing creation tools. It has the capability to tie together and integrate text and graphics from several windows tools using the clipboard, dynamic data exchange, or object linking and embedding. The following are several word processors that are useful for O-O Modeling in the Microsoft Windows environment: Microsoft Word, Lotus AmiPro, Word Perfect, and Frame Technology FrameMaker.
An O-O CASE tool is important to create O-O diagrams,
text specifications, and C++ code generation. A scripting CASE
tool provides a capability to create custom scripts for code generation
and report creation. With scripts an end-user can write short
scripts that access and manipulate the information in a model
exactly as he or she desires. Scripts provide great flexibility
and extendibility. An O-O CASE tool is very helpful for O-O modeling
because it provides a structure to create diagrams, text specifications,
and code. Additionally, an O-O CASE tool saves time because diagrams,
text specifications, and code may be quickly created and changed.
Finally, an O-O CASE tool is valuable for training and education
to understand the various O-O entities, O-O relationships, and
O-O methodologies. The following are several O-O CASE tools that
are useful in the Microsoft Window environment: MicroGold With
Class , OOTool from Roman M. Zielinski in Norsborg, Sweden, Mark
V ObjectMaker, ProtoSoft Paradigm Plus, Object International Playground,
and Rational Rose.
The primary CASE tool used in this tutorial is the With Class CASE tool. This tool provides support for all major diagrams and specifications in the Rumbaugh OMT. It provides a script language to create reports and to generate source code in C++ and other languages.
A GUI interface builder is important to design and prototype the GUI interface. The GUI interface is an important aspect of an O-O system because it provides direct contact with the user. Often prototyping the GUI interface is extremely valuable to understand the user requirements. GUI interface builders will be used in modeling systems later in this tutorial. The following are several GUI Interface Builders that are useful in the Microsoft Window environment: ProtoView Development Protogen +, Blue Sky WindowsMaker, Borland C++ Resource Workshop, and Microsoft Visual C++ App Studio.
The C++ development environment is important to develop working system prototypes and to develop implementation products. The environment has many tools, e.g. class browser, compiler, linker, debugger, GUI builder, and class libraries. Important C++ development environments in the Microsoft Windows environment are the Borland C++, Microsoft Visual C++, and Symantec C++.
The primary objective of O-O modeling is to describe and specify a system to lead to a high quality software program. A quality software program has the major S/W quality factors of correctness, reliability, and extendibility as described by Bertrand Meyer in Object-Oriented Software Construction [Meyer-88]. Other S/W quality factors include understandability, adaptability, reusability, efficiency, portability, traceability, completeness, confirmability, modularity, error handling, uniformity, and ease of use.
Correctness is the ability of a system to perform in accordance with its stated purpose and requirements. Correctness is "doing what it is supposed to do". It ensures that correct values are always computed. It ensures that there is correct stimulus response behavior of a system or object. Correctness is to avoid errors. For example, it is important for a bank automatic teller machine to correctly verify a user card, personal identification number, and to correctly update account balances.
Reliability is the ability of a system to perform correctly for long periods of time. Reliability is sometimes referred to as "robustness", i.e. the ability of a system or object to perform correctly even under abnormal conditions. It ensures that a system or object has the capability to detect errors and faults and to take appropriate action. For example, it is important for a bank automatic teller machine to operate for long periods of time without problems and errors.
Extendibility is the ability to easily change and update a system. It deals with making both minor changes to the existing entity and making major enhancements to the entity. Changes and enhancements should not cause a "ripple effect" of undesired problems in other entities. It means that a system can be easily modified and extended. For example, it is important for a bank to easily make changes and modifications to a bank automatic teller machine without causing undesired side effects and problems.
Reusability is the ability to use or reuse an application or a part of an application for new applications. It involves using predefined classes and objects when they are available to reduce the amount of new code in an application. It also involves modifying an application for a new use. For example, the bank ATM shown below was modified to handle rental car reservations as shown below.
In summary, to create a high quality software system, we model the system from various points of view with various documentation products. This is to lead to a software system with excellent S/W quality factors of correctness, reliability, and extendibility.
How do we achieve the software quality factors of
correctness, reliability, extendibility, and reusability? We can
apply certain techniques or guidelines such as encapsulation,
loose coupling, strong cohesion, aggregation with propagation
of operations, and subclasses with polymorphic operations. These
techniques are shown below.
Effective Techniques Software Quality Factors
Encapsulation Correctness High
Weak Coupling Reliability Quality
Strong Cohesion ==> Extendibility ==> S/W
Aggregation & Propagation Reusability
Subclasses & Polymorphism
Encapsulation means to combine (encapsulate) data and the operations on the data. Encapsulation is also known as information hiding in which data and some operations are hidden and inaccessible. An important aspect of encapsulation is to separate the "what" and the "how". The "what" is the public interface of available operations. The "how" is the private implementation of data and some operations. In the physical world a vending machine is a good example of encapsulation. The vending machine encapsulates the products, such as soft drinks and the operations on the products, such as select_product and dispense_product. There is information hiding because a user cannot directly manipulate the products. A user can only use the buttons and levers on the vending machine. The vending machine case hides the internal storage of the products. The vending machine separates the "what", represented by the visible (public) buttons and levers, from the private implementation, which is the storage and dispensing mechanism.
A good example of encapsulation in software is a collection class. The collection class encapsulates the items in the collection, such as numbers, strings, etc., and the operations on the items in the collection, such as add_item and remove_item. There is information hiding because a user cannot directly manipulate an item in the collection. A user can only invoke the operations. The collection hides the internal storage of the items. The collection separates the "what", the public operations add_item and remove_item, from the private implementation, the storage of the items. A class or other module that has a public interface and private implementation is also referred to as an abstract data type [Cleaveland-86].
Weak coupling is another technique to achieve the
software quality factors. Weak coupling is to have a low degree
of interconnectivity of entities. The general term coupling refers
to the degree of interconnectivity, joining, and linking of entities.
With weak coupling a change in one entity will generally have
a minimum change in another entity. It is also referred to as
loose coupling. Strong coupling is to have a high degree of interconnectivity
of entities. With strong coupling a change in one entity may result
in a change to the other entity.
In the physical world, an example of weak coupling is a boy and girl walking down a street talking. There is a low degree of interconnectivity between the boy and the girl. A change in the boy or the girl will have a minimum change in the other. If the boy accidentally stumbles, he will probably not cause the girl to stumble. Another example of loose coupling is a modular stereo set as shown in the figure below. The components are connected together (coupled) with easy to change cables. There is a low degree of interconnectivity because a component may be easily changed without affecting other components. In software an example of weak coupling would be the several objects in an automatic teller machine that have a moderate (not excessive) small number of association relationships. Therefore a change in one of the objects, such as a card object will not cause an undesired change in the another object, such as an account object.
In the physical world, an example of strong coupling would be two steel beams that are welded together. There is a high degree of interconnectivity between the beams. To move one of the beams you must move the other. Another example is a single unit stereo system with soldered hard wired cables. There is a high degree of interconnectivity between the components. A component cannot be easily changed without affecting other components. In software an example of strong coupling is a group of objects with a large number of relationships resulting in an intertwined organization. A change in one object may result in an undesired side-effect in another object.
Strong cohesion is a technique to achieve software
quality factors. Cohesion is the degree of internal relatedness
of elements within a larger, more complex entity. Each element
contributes to accomplishing the entity's purpose. Strong cohesion
is a high degree of internal relatedness of elements. With strong
cohesion there are no "out of place" elements. All elements
contribute to the entity's purpose. Weak cohesion is a low degree
of internal relatedness of elements. With weak cohesion there
are elements that are "out of place" and that do not
contribute the entity's purpose.
In the physical world an example of strong cohesion
is a highly trained medical hospital emergency room team as shown
in the figure below. All its members, for example doctors, nurses,
orderlies, etc. all work together to contribute to the organization's
purpose to provide excellent medical care. There are no "out
of place" members. We would say the hospital emergency room
team is "highly cohesive". In software a bank account
object has strong cohesion if all its elements (attributes and
operations) support the object's purpose. There are no "out
of place" attributes or operations.
An example of weak cohesion is a poorly managed government
drivers' license bureau. All its elements, such as managers, clerks,
secretaries, etc. do not all work together. Members are "standing
around" and "out of place". In software an object
has weak cohesion if it has elements, for example attributes and
operations that don't support the object's purpose. There are
attributes and operations that are "out of place".
Two other techniques to achieve software quality factors are the use of aggregation ("part of" relationship) with the propagation of operations and subclasses ("is a" relationship) with polymorphic operations. These techniques will be presented in the chapter dealing with relationships.
An object-oriented methodology has a defined set of entities (system, class, object, etc.), graphic symbols, diagrams, forms, rules, and procedures. It is a process that generally covers the entire software lifecycle from requirements to implementation. Many CASE tool supports a subset graphic notation for several object-oriented methodologies, e.g. Rumbaugh Object Modeling Technique (OMT), Coad/Yourdon Object-Oriented Analysis and Design (OOA/OOD), Booch Object-Oriented Design (OOD), and Shlaer Mellor OOA/OOD. The following is a very brief overview of these methodologies.
This O-O methodology is documented in Object-Oriented
Modeling and Design by James Rumbaugh et. al [Rumbaugh-91].
It has a strong data modeling origin. It has a very comprehensive
graphic notation. Analysis in OMT consists of the Object Model,
Dynamic Model, and Functional Model which will be described shortly.
Analysis is followed by system design and detailed design. O-O
Modeling presented in this tutorial covers the OMT Analysis Model.
Inputs Analysis System Detailed Design
Model Design Model Model
--> --> -->
System Object Model System - Detailed Object Model
Require Dynamic Model Subsystem Detailed Dynamic Model
ments Functional Architecture Detailed Functional
Model Model
This O-O methodology is documented in Object-Oriented Analysis and Object-Oriented Design by Peter Coad and Ed Yourdon [Coad-91a and Coad-91b]. It has a strong data modeling origin. It has a simple graphic notation. OOA consists of identifying and organizing classes from different points of view called layers. OOD consists of refining the OOA model for the human interface, problem domain, data management, and concurrent task management.
This O-O methodology is documented in Object-Oriented Design with Applications by Grady Booch [Booch-94]. It has a very strong real-time and message passing origin. It has an extensive, comprehensive graphic notation. OOD consists of modeling a system by identifying, organizing, and specifying subsystems, classes, objects, implementation modules and processes.
This O-O methodology is documented in Object-oriented Development The Fusion Method by Derek Coleman et al [Coleman-93]. The Fusion Method consists of an analysis phase and a design phase. Analysis has the object model and interface model. Design has the object interaction graph, visibility graph, inheritance graph, and class description.
This O-O methodology is documented in Object Lifecycles
- Modeling the World in States by Sally Shlaer and Stephen
Mellor [Shlaer-92]. OOA consists of information (data) models,
state models, and process models similar to the OMT object model,
dynamic model, and functional model. OOD consists of refining
the OOA models for an implementation environment.
In this tutorial we will use the Object Modeling Technique (OMT). OMT supports the entire software development lifecycle from requirements to implementation source code. However, we will only cover the early portion of the software lifecycle. In O-O modeling in this tutorial, we will identify, organize, and prototype initial classes and objects in a system. We will not discuss specifics of system design or detailed design. In this tutorial select Rumbaugh OMT from the CASE tool methodology menu.
O-O modeling is a process to describe systems. A system is an independent entity that consists of classes, objects, and relationships. It is an important process for the development of O-O systems with O-O languages, such as C++. O-O CASE (computer aided software engineering) tools are useful to create O-O diagrams, text specifications, code generation, and reverse engineering of diagrams from code. The With Class CASE tools from MicroGold Software is a highly capable CASE tool with a scripting language.