Title: Chapter 2 The ObjectOriented Paradigm and UML: An Overview
1Chapter 2 - The Object-Oriented Paradigm and
UML An Overview
CIS 476/566 Software Architecture and Design
Patterns
- Dr. Brahim Medjahed
- brahim_at_umich.edu
2Outline
- The Object-Oriented (OO) Paradigm
- Software Model
- UML (Unified Modeling Language)
3Important
- This is not an OO or UML course
- Not a complete overview of OO and UML
- Focus on the concepts we will use the most in
this course - More detailed description
- Object-Oriented Design with Applications (Second
Edition) by Grady Booch - UML Distilled Third Edition by Martine Fowler,
Addison Wesley
4The Object-Oriented (OO) Paradigm
5Object
- Centered on the concept of object
- An object is
- Conceptual level set of responsibilities
- Specification level set of methods (behaviors)
- Implementation level code and data
- Objects public interface set of methods
callable by other objects
6Class and Instance
- Class defines the types of objects based on the
responsibilities these objects have - Instance a particular example of a class (it is
always an object - Instantiation the process of creating an
instance of a class (i.e., object)
7Inheritance
- A class inherits from another class if it
receives some or all of the qualities (e.g.,
methods) of that class - Starting class base, super, parent, generalized
class - Inheriting class derived, sub, child,
specialized class
8Visibility
- For data and methods
- Public anything can see it
- Private only object from this class can see it
- Protected only objects of this class and derived
classes can see it
9Visibility (contd)
- A derived class can define its own new members,
and redefine members of the parent class. - If a method, m1(), is redefined in derived class,
then a message sent to an object, d_obj, of the
derived class will cause the redefined m1 to be
invoked. - A user of d_obj can send a message
d_obj.Parentm1() to use m1() defined in the
parent class.
10Public and Private Derivation
11Abstract and Concrete Class
- Abstract Class defines what a set of related
classes can do - Act as a placeholder for other classes
- Concrete Class a class that implements a
particular type of behavior for an abstract class - Derived from abstract classes
12Polymorphism
- Ability to refer to different derivations of a
class in the same way, but getting the behavior
appropriate to the derived class being referred
to - Example class shape
- Polymorphism enables the programmer to define
different area methods for any number of derived
classes, such as circles, rectangles and
triangles. No matter what shape an object is,
applying the area method to it will return the
correct results.
13Software Models
14What is a Software Model?
- A description (specification) of the software
which - Abstracts out irrelevant detail
- Presents the software using higher-level
abstractions
15Example
case mainState of initial send(I am
here) end Off case event of
on send(oa,5) next(On) end off
next(Off) end end On case event
of off next(Off) end done
terminate end end end
16How Models are Used?
- To detect errors and omissions in designs before
committing full resources to full implementation - Through (formal) analysis and experimentation
- Investigate and compare alternative solutions
- To communicate with stakeholders
- Clients, users, implementers, testers,
documenters, etc. - To derive implementation
17Characteristics of Good Software Models
- Abstract Emphasize important aspects while
removing irrelevant ones - Understandable Expressed in a form that is
readily understood by observers - Accurate Faithfully represents the modeled
system - Predictive Can be used to derive correct
conclusions about the modeled system - Inexpensive Much cheaper to construct and study
than the modeled system
18The Unified Modeling Language (UML)
19What is UML?
- Unified Modeling Language
- The standard for software models in the
object-oriented community - Visual defines a drawing notation with
semantics - Has several types of diagrams to model the
- Structure (e.g., Class Diagrams)
- Behavior (Sequence Diagrams)
20UML Diagram Types
21The Class Diagram
- Shows the relationships between classes
- Show the static features of the system and do not
represent any particular processing
22UML Class
- Attributes/properties in the middle
Public - Private
Protected
23Adding Comments to a UML Class
Contains GPA
24Basic Notations
- We will sometimes adopt GoF notations (page 363)
- OMT (Object Modeling Techniques)
- Not completely similar to UML
- Abstract Classes Italicized
- Inheritance triangle connecting a subclass to
its parent - Aggregation relationship
- Arrow-headed line with a diamond at the base
- The arrow points to the class that is aggregated
25Basic Notations (contd)
- Composition Whole-part relationship
- The whole has responsibility for the parts. If
the whole is deleted, all the parts will be
deleted as well. - Represented by a filled diamond at the base
- Acquaintance arrow-headed line
- Object keeps a reference to another object
- Instantiation Which classes instantiate which
others - Dashed arrow-headed line
- Cardinality filled circle to mean more than once
- Multiple objects are being referenced or
aggregated
26UML Sequence Diagrams
- Models Interaction
- Used to show interaction between the objects in
sequential order. - UML 2.0 sequence diagram improved over UML
version 1 in the area of modeling logic in
sequences
27Basic Notations
Object
28Example
Registrar office
student
Register for class
Check prerequisite
Prerequisite meet
Check seating of class
Still room in the class
Tuition and fees