Object Oriented Analysis and Design Using The UML: Introduction To Object Orientation
Object Oriented Analysis and Design Using The UML: Introduction To Object Orientation
Object Oriented Analysis and Design Using The UML: Introduction To Object Orientation
Understand the basic principles of object orientation Understand the basic concepts and terms of object orientation and the associated UML notation Appreciate the strengths of object orientation Understand some basic UML modeling mechanisms
1. 2. 3. 4.
Basic Principles of Object Orientation Basic Concepts of Object Orientation Strengths of Object Orientation General UML Modeling Mechanisms
1.
Object Orientation
Encapsulation
Abstraction
Modularity
Hierarchy
What is Modularity?
What is Hierarchy?
Increasing abstraction
Asset
Levels of abstraction
BankAccount Security RealEstate
Savings Checking
Decreasing abstraction
Stock
Bond
Elements at the same level of the hierarchy should be at the same level of abstraction
Basic Principles of Object Orientation Basic Concepts of Object Orientation Strengths of Object Orientation General UML Modeling Mechanisms
Object Class Attribute Operation Interface (Polymorphism) Component Package Subsystem Relationships
An object is a concept, abstraction, or thing with sharp boundaries and meaning for an application An object is something that has:
Representing Objects
Object Class Attribute Operation Interface (Polymorphism) Component Package Subsystem Relationships
What is a Class?
A class is a description of a group of objects with common properties (attributes), behavior (operations), relationships, and semantics A class is an abstraction of objects.
OO Principle: Abstraction
Representing Classes
Professor
Professor Kiims
Class Compartments
It defines the structure and behavior of each object in the class It serves as a template for creating objects
Objects
Class
Professor
Professor Smith Professor Mellon
Professor Jones
Object Class Attribute Operation Interface (Polymorphism) Component Package Subsystem Relationships
What is an Attribute?
Class
Object
Attribute
Attribute Value
:CourseOffering
number = 101 startTime = 10.00 endTime = 10.55
CourseOffering
Class no startTime endTime
:CourseOffering
number = 102 startTime = 10.55 endTime = 11.50
Object Class Attribute Operation Interface (Polymorphism) Component Package Subsystem Relationships
What is an Operation?
CourseOffering
Class
addStudent deleteStudent getStartTime getEndTime
Operation
Object Class Attribute Operation Interface (Polymorphism) Component Package Subsystem Relationships
What is Polymorphism?
Manufacturer A
Manufacturer B
Manufacturer C
OO Principle: Encapsulation
What is an Interface?
Shape
Pyramid Draw Move Scale Rotate
abstract methods
Cube
Interface Representations
Elided/Iconic Representation (lollipop)
Tube Pyramid
Shape
Cube
Tube <<interface>>
Shape
Pyramid
Cube
Object Class Attribute Operation Interface (Polymorphism) Component Package Subsystem Relationships
What is a Component?
A non-trivial, nearly independent, and replaceable part of a system that fulfills a clear function in the context of a well-defined architecture A component may be
OO Principle: Encapsulation
Component Interface
Object Class Attribute Operation Interface (Polymorphism) Component Package Subsystem Relationships
What is a Package?
A package is a general purpose mechanism for organizing like elements into groups A model element which can contain other model elements
Package Name
OO Principle: Modularity
Uses
Object Class Attribute Operation Interface (Polymorphism) Component Package Subsystem Relationships
What is a Subsystem?
A combination of a package (can contain other model elements) and a class (has behavior) Realizes one or more interfaces which define its behavior Interface is an abstract class. Subsystem implements (realizes) the interface (interfaces)
Realization Subsystem
Interface
Interface
Components are the physical realization of an abstraction in the design Subsystems can be used to represent the component in the design
Design Model Implementation Model
<<subsystem>>
Component Name
Component Interface
Object Class Attribute Operation Interface (Polymorphism) Component Package Subsystem Relationships
Relationships
Association
Aggregation Composition
Relationships: Association
Professor
Works for
University
Association Class
Role Names
Professor
Employee Employer
University
Relationships: Aggregation
A special form of association that models a whole-part relationship between an aggregate (the whole) and its parts
Whole Part
Student
Schedule
Relationships: Composition
Whole
Part
Student
Schedule
Aggregation
The number of instances (that is, objects) of one class related to ONE instance of another class Specified for each end of the association
Associations and aggregations are bi-directional by default, but it is often desirable to restrict navigation to one direction
Association: Multiplicity
1 0..* * 1..*
Student
0..*
Schedule
Navigation
A student has zero or more schedules. (Multiplicity) Note: Aggregation: has_a and whole-part relationship. (type of Association)
Relationships: Dependency
A relationship between two model elements where a change in one may cause a change in the other Non-structural, using relationship Can actually say the Client uses the Supplier.
Client Supplier
Class
Component
Package
Dependency relationship
Client
Supplier
ClientPackage
SupplierPackage
Dependency relationship
A relationship among classes where one class shares the structure and/or behavior of one or more classes Defines a hierarchy of abstractions in which a subclass inherits from one or more superclasses
Relationships: Generalization
Ancestor
Generalization Relationship Subclasses inherit both attributes and methods from base (parent) class.
Checking Savings GetInterest() Withdraw()
Subclasses
Withdraw()
Descendents
Animal
Airplane
Helicopter
Bird
Wolf
Horse
Use multiple inheritance only when needed, and always with caution !
A subclass inherits its parents attributes, operations, and relationships A subclass may:
Add additional attributes, operations, relationships Redefine inherited operations (use caution!)
Common attributes, operations, and/or relationships are shown at the highest applicable level in the hierarchy
Superclass (parent)
weight licenseNumber
register( )
owner 0..* 1
Person
generalization
Subclass
Car size
Trailer
Relationships: Realization
One classifier serves as the contract that the other classifier agrees to carry out Found between:
Subsystem
Interface
Canonical form
Elided form
Use Case
Use-Case Realization
Basic Principles of Object Orientation Basic Concepts of Object Orientation Strengths of Object Orientation General UML Modeling Mechanisms
4. Stereotypes
Classify and extend the UML notational elements Define a new model element in terms of another model element May be applied to all modeling elements Represented with name in guillemets or as a <<boundary>> different icon MyBoundaryClass
MyBoundaryClass
Notes
A Note can be added to any UML element Notes may be added to add more information to the diagram It is a dog eared rectangle The note may be anchored to an element There can be up to one MaintainScheduleForm per with a dashed line MaintainScheduleForm
user session.
Tagged Values
Extensions of the properties, or specific attributes, of a UML element Some properties are defined by UML
Constraints
Department
This notation is used to capture two relationships between Professor-type object and Department-type objects; where one relationship is a subset of another.
Shows how UML can be tailored to correctly modeling exact relationships.
What is an Attribute? What is an Operation? What is an Interface? What is Polymorphism? What is a Component?
(continued)
How does it relate to a Component? How does it relate to a package? How does it relate to a class?
Name the four basic UML relationships and describe each. Describe the strengths of object orientation. Name and describe some general UML mechanisms. What are stereotypes?