• No results found

Object Oriented Analysis and Design Using the UML

N/A
N/A
Protected

Academic year: 2021

Share "Object Oriented Analysis and Design Using the UML"

Copied!
55
0
0

Loading.... (view fulltext now)

Full text

(1)

Object Oriented Analysis and Design

Using the UML

Introduction to Object Orientation

(2)

Objectives: 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

(3)

Introduction to Object Orientation Topics

 1. Basic Principles of Object Orientation

 2. Basic Concepts of Object Orientation

 3. Strengths of Object Orientation

 4. General UML Modeling Mechanisms

(4)

Object Orientation

Encapsulation

Abstraction Hierarchy

Modularity

1. Basic Principles of Object

Orientation

(5)

Salesperson Not saying which

salesperson – just a

salesperson in general!!!

Customer Product

What is Abstraction?

(6)

 Hide implementation from clients

 Clients depend on interface – only!

 Clients do not need to know ‘how’ the server operates or provides the services!

Improves Resiliency

What is Encapsulation?

How does an object encapsulate?

What does it encapsulate?

DISCUSS!!!!!

(7)

Order Processing System

Billing Order Entry

Order Fulfillment

What is Modularity?

 The breaking up of something complex into manageable pieces

(8)

Decreasing abstraction Increasing abstraction

Asset

RealEstate

Savings

BankAccount

Checking Stock

Security

Bond

Elements at the same level of the hierarchy

What is Hierarchy?

 Levels of abstraction

(9)

Introduction to Object Orientation Topics

 Basic Principles of Object Orientation

 Basic Concepts of Object Orientation

 Strengths of Object Orientation

 General UML Modeling Mechanisms

(10)

2. Basic Concepts of Object Orientation

 Object

 Class

 Attribute

 Operation

 Interface (Polymorphism)

 Component

 Package

 Subsystem

 Relationships

(11)

A More Formal Definition

 An object is a concept, abstraction, or thing with sharp boundaries and meaning for an application

An object is something that has:

State

Behavior

Identity

(12)

: Professor

Professor Clark

a + b = 10

ProfessorClark : Professor

ProfessorClark

Class Name Only

Object Name Only

Class and Object Name

Representing Objects

 An object is represented as rectangles with underlined names

(13)

Basic Concepts of Object Orientation

 Object

 Class

 Attribute

 Operation

 Interface (Polymorphism)

 Component

 Package

 Subsystem

 Relationships

(14)

OO Principle: Abstraction

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….

 An object is an instance of a class

 A class is an abstraction in that it:

 Emphasizes relevant characteristics

 Suppresses other characteristics

(15)

Professor

Professor Clark

a + b = 10

Representing Classes

 A class is represented using a compartmented rectangle

(16)

Professor nameempID

create( ) save( ) delete( ) change( ) Class Name

Attributes Operations

Class Compartments

 A class is comprised of three sections

 The first section contains the class name

 The second section shows the structure (attributes)

 The third section shows the behavior (operations)

(17)

Objects Class

Professor Smith Professor Mellon

Professor

The Relationship Between Classes and Objects

A class is an abstract definition of an object

It defines the structure and behavior of each object in the class

It serves as a template for creating objects

(18)

Basic Concepts of Object Orientation

 Object

 Class

 Attribute

 Operation

 Interface (Polymorphism)

 Component

 Package

 Subsystem

 Relationships

(19)

:CourseOffering

number = 101 startTime = 900 endTime = 1100

:CourseOffering

number = 104 startTime = 1300 endTime = 1500

CourseOffering

number startTime endTime

Class

Attribute

Object

Attribute Value

What is an Attribute?

(20)

Basic Concepts of Object Orientation

 Object

 Class

 Attribute

 Operation

 Interface (Polymorphism)

 Component

 Package

 Subsystem

 Relationships

(21)

CourseOffering

addStudent deleteStudent getStartTime getEndTime

Class

Operation

What is an Operation?

(22)

Basic Concepts of Object Orientation

 Object

 Class

 Attribute

 Operation

 Interface (Polymorphism)

 Component

 Package

 Subsystem

 Relationships

(23)

Manufacturer A Manufacturer B

Manufacturer C

OO Principle:

Encapsulation

What is Polymorphism?

 The ability to hide many different

implementations behind a single interface

(24)

Tube

Pyramid

Cube

Shape

Draw Move Scale Rotate

<<interface>>

Realization relationship.

Tube, Pyramid, and Cube

What is an Interface?

 Interfaces formalize polymorphism

 Interfaces support “plug-and-play”

architectures

abstract methods

(25)

Tube

Pyramid

Shape

Draw Move Scale Rotate

<<interface>>

Tube

Pyramid

Shape Cube

Elided/Iconic Representation (“lollipop”)

Canonical

(Class/Stereotype) Representation

Interface Representations

(26)

Basic Concepts of Object Orientation

 Object

 Class

 Attribute

 Operation

 Interface (Polymorphism)

 Component

 Package

 Subsystem

 Relationships

(27)

Source File Name

<<EXE>>

Executable Name

OO Principle:

Encapsulation

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

A source code component

A run time component or

An executable component

<<DLL>>

Component

(28)

Basic Concepts of Object Orientation

 Object

 Class

 Attribute

 Operation

 Interface (Polymorphism)

 Component

 Package

 Subsystem

 Relationships

(29)

Package Name OO Principle:

Modularity

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

Uses

Organize the model under development

A unit of configuration management

(30)

Basic Concepts of Object Orientation

 Object

 Class

 Attribute

 Operation

 Interface (Polymorphism)

 Component

 Package

 Subsystem

 Relationships

(31)

OO Principles: Encapsulation and Modularity

<<subsystem>>

Subsystem Name Interface

Interface

Realization

Subsystem

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)…

(32)

Component Name

Design Model Implementation Model

<<subsystem>>

Component Name Component

Interface

Component Interface

OO Principles: Encapsulation and Modularity

Subsystems and Components

Components are the physical realization of an abstraction in the design

 Subsystems can be used to represent the component in the design

(33)

Basic Concepts of Object Orientation

 Object

 Class

 Attribute

 Operation

 Interface (Polymorphism)

 Component

 Package

 Subsystem

 Relationships

(34)

Relationships

 Association

Aggregation

Composition

 Dependency

 Generalization

 Realization

(35)

Professor Works for University

Class

Association Association Name

Professor University

Role Names

Relationships: Association

 Models a semantic connection among classes

Add these descriptions via Open Specification in Rose

(36)

Student Schedule

Whole

Aggregation This is sometimes

Part

Relationships: Aggregation

A special form of association that models a whole-part relationship between an

aggregate (the whole) and its parts

(37)

Student Schedule

Whole

Aggregation

Part

Relationships: Composition

A form of aggregation with strong ownership and coincident lifetimes

The parts cannot survive the whole/aggregate

(38)

Association: Multiplicity and Navigation

 Multiplicity defines how many objects participate in a relationships

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

If navigation is restricted, an arrowhead is

added to indicate the direction of the navigation

(39)

Association: Multiplicity

2..4 0..1 1..*

0..*

1

*

 Unspecified

 Exactly one

 Zero or more (many, unlimited)

 One or more

 Zero or one

 Specified range

 Multiple, disjoint ranges 2, 4..6

(40)

Student 1 0..* Schedule

Multiplicity

Navigation

Example: Multiplicity and Navigation

A student has zero or more schedules. (Multiplicity)

Note: Aggregation: ‘has_a’ and whole-part relationship. (type of Association)

(41)

Client Supplier

Package

ClientPackage SupplierPackage

Client Supplier

Class

Dependency relationship

Dependency Component

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.

(42)

 Relationships:

Generalization

 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

Single inheritance

Multiple inheritance

 Generalization is an “is-a-kind of”

relationship, or simply, “is_a” relationship.

(43)

Account balance namenumber

Withdraw()

CreateStatement()

Checking Withdraw()

Savings GetInterest()

Superclass (parent)

Subclasses

Generalization Relationship Subclasses inherit both

attributes and methods from base (parent) class.

Ancestor

Example: Single Inheritance

 One class inherits from another

(44)

Airplane Helicopter Wolf Horse

FlyingThing Animal

Bird

multiple inheritance

Use multiple inheritance only when needed, and always with caution !

Example: Multiple Inheritance

 A class can inherit from several other classes

(45)

What Gets Inherited?

 A subclass inherits its parent’s 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

(46)

Truck tonnage GroundVehicle

weight

licenseNumber

Car

owner

register( )

getTax( )

Person 0..*

Trailer

Superclass 1

(parent)

Subclass

generalization

size

Example: What Gets Inherited

(47)

Elided form Subsystem

Interface

Canonical form

Relationships: Realization

 One classifier serves as the contract that the other classifier agrees to carry out

 Found between:

  Interfaces and the classifiers that realize them

(48)

Introduction to Object Orientation Topics

 Basic Principles of Object Orientation

 Basic Concepts of Object Orientation

 Strengths of Object Orientation

 General UML Modeling Mechanisms

(49)

<<boundary>>

MyBoundaryClass MyBoundaryClass

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 different icon

(50)

There can be up to one MaintainScheduleForm per user session.

MaintainScheduleForm

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 with a dashed line

(51)

PersistentClass

{persistence} anObject : ClassA

{location=server}

Tagged Values

 Extensions of the properties, or specific attributes, of a UML element

 Some properties are defined by UML

 Persistence

 Location (e.g., client, server)

 Properties can be created by UML modelers for any purpose

(52)

Professor Member Department

Department Head {subset}

1..*

1

1

1

Constraints

 Supports the addition of new rules or modification of existing rules

This notation is used to capture two relationships between Professor-type objects and Department-type objects; where one relationship is a subset of another….

Shows how UML can be tailored to correctly modeling exact relationships….

(53)

Review: Introduction to Object Orientation

What are the four basic principles of object orientation?

Provide a brief description of each.

What is an Object and what is a Class?

What is the difference between them?

What is an Attribute?

What is an Operation?

What is an Interface?

What is Polymorphism?

What is a Component?

(54)

Review: Introduction to Object Orientation (cont.)

What is a Package?

What is Subsystem?

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?

Name some common uses of stereotypes.

References

Related documents

To conclude these paragraphs, there are several indications that collaboration between (medical) students in the informal context could increase student learning.. are

 Our Design Model will then take the artifacts from Analysis Modeling (analysis classes) and create our Use Case Realizations:..  Static View: Design

This training seminar will ensure that you understand how to decide rationally what maintenance activities to outsource and what not, how to select the best

The undersigned authorizes Martinsville-Henry County Economic Development Corporation to verify any and all information furnished in connection with this application. Everything

Design Objects, Class hierarchy, inheritance, polymorphism, object relationships and associations, aggregations and object containment, object persistence, meta-classes,

Q: What was the real name of the great American short writer &#34; O Henry&#34; A: William Sydney Porter.. Q: &#34;A farewell to arms&#34; is

When applied to measures with overlap in item content across correlated constructs, in the absence of a global factor and cross-loadings, CFA is forced to account for the shared

[r]