Sie sind auf Seite 1von 37

Object Oriented Modeling

System modelling

System modelling helps the analyst to understand the functionality of the system and models are used to communicate with customers. Different models present the system from different perspectives
Structural perspective showing the system or data architecture; Behavioural perspective showing the behaviour of the system; External perspective showing the systems context or environment.

Object Oriented Methodology

Building a model of an application domain and then adding implementation details to it. Following four stages: Analysis; System Design; Object Design; Implementation.

Three Models
Object

Model describes the static structure of objects in the system and their relationships. Dynamic Model describes the aspect of the system that change over time, i.e. interaction among objects. Functional Model describes data value transformation in the system.

Object Model
Describes

a system- Identity - Relationship to other objects - Their attributes - And their operations.

the structure of objects in

Dynamic Model
Describes

those aspects of the system concerned with time and sequencing of operationsEvents that make change Sequence of events States that define context of events And organization of events and states.

Functional Model
Describes

those aspects of the system concerned with transformation of valuesFunctions

Mappings Constraints Functional dependencies

Is

represented with Data Flow Diagrams.

Object models and the UML

The UML is a standard representation devised by the developers of widely used object-oriented analysis and design methods. It has become an effective standard for object-oriented modelling.

Object Model Notations


Object classes are rectangles with the name at the top, attributes in the middle section and operations in the bottom section;
Employee name: string address: string dateOfBirth: Date employeeNo: integer socialSecurityNo: string department: Dept ma nager: Employee salary: integer status: {current, left, retired} taxCode: integer . .. join () leave () retire () changeDetails ()

Object Model Notations (Contd.)


Relationships between object classes (known as associations) are shown as lines linking objects

Employee

is-member-of

Department

is-managed-by

manages

Manager

Associations
Connection Solid

between objects

line

Direction optional Arrowhead depends on meaning


Name

(optional) Multiplicities (optional) Visibility (optional)

Association Examples
Order

Not UML

LineItem CatalogItem -Price

LineItem CatalogItem -Price

LineItem CatalogItem -Price

Order 1 1..*

LineItem 1 1 CatalogItem -Price

Attribute Elements
Visibility Name Type Multiplicity Default

(only required element)

value Properties Example:


- name:String [1] = Bob {readOnly}

Attribute Types
Instance

attributes

Each object of the class has its own attribute Changing the value of the attribute affects only the containing object
Class

attributes

Only one instance of the attributes for all objects of the class Changing the value of the attribute affects all objects of the class Underline the attribute

Attribute Type Example


Foo1 -Bar : int Foo2 -Bar : int

A : Foo1 Bar : int

B : Foo1 Bar : int

A : Foo2

B : Foo2

-Bar : int

Library class hierarchy


Libr item ary Catalogu e n umber Acqu is ition d ate Co st T e yp Status Nu mber o f co pies Acqu ir () e Catalogu e () Disp os e () Iss ue () Retu rn ()

Pu blis hed item Title Pu blis her

Reco rded item Title Medium

Bo ok A or uth Ed ition Pu blicatio n da te ISBN

Magazin e Y ear Iss ue

Film Director Date of releas e Distributo r

Co mpu ter pro gram V io n ers Platf m or

User class hierarchy


Libr u ser ary Name Address Ph on e Reg istr atio n # Reg ister () De-reg ister ()

Read er Af filiatio n

Bo rrower Items o n loan Max. lo an s

Staff Depar tment Depar tment p ho ne

Stu den t Majo r s ub ject Ho me ad dress

Multiple inheritance
Bo ok Auth or Ed ition Pu blicatio n da te ISBN Vo ice record in g Sp eak er Du ratio n Reco rdin g date

T in g bo ok alk # Tapes

Object aggregation
An

aggregation model shows how classes that are collections are composed of other classes.

Aggregation

models are similar to the part-of relationship in semantic data models.

Object aggregation

Generalization
Models

the concept of inheritance Subclasses inherit the attributes and operations of all their superclasses Objects of a subclass should be substitutable for objects of their superclasses Uses hollow triangle arrowhead on superclass

Generalization Example1
Shape +draw()

Rectangle +draw()

Triangle +draw()

Circle +draw()

Square +draw()

Generalisation Example2
Employee

Ma nager budgetsControlled dateAppointed

Programmer project progLanguage

Project Ma nag er projects

De pt. Ma nager dept

Strategic Ma nag er responsibilities

Constraints
A restriction in the design Documented inside curly braces {} attached to any diagram element

ATM Transaction
{value >= 0} amount : Money {value is multiple of $20} balance : Money

ATM Transaction
{value >= 0} amount : Money {value is multiple of $20} balance : Money

Putting the Pieces Together


Order -dateReceived : Date -isPrepaid : Boolean -number : Integer -total : Currency +close() : void +dispatch() : void 1 Customer -name : String -address : Address -CreditRating : String +GetCreditRating() : String{query,sequential} * 1

{if Order.Customer.GetCreditRating() is "poor", then Order.isPrepaid must be true}

CorporateCustomer -ContactName : String -CreditLimit : Currency +Remind() : void +BillForMonth() : void

PersonalCustomer -CreditCardNumber : String

line items

* 0..1 Product * 1 sales rep

OrderLine -isSatisfied : Boolean -price : Currency -quantity : Integer

Employee

Abstract Classes
Used to hold common operations and data Used in inheritance hierarchy

Derived (child) classes provide implementations

Documented with class name in italics


Can also use {abstract} property
Shape +move() +erase() : void +draw() : void

Shape {abstract} +move() +erase() : void {abstract} +draw() : void {abstract}


Triangle +draw() : void +erase() : void

Circle +draw() : void +erase() : void

Rectangle +draw() : void +erase() : void

Object behaviour modelling


A

behavioural model shows the interactions between objects to produce some particular system behaviour that is specified as a usecase. diagrams (or collaboration diagrams) in the UML are used to model interaction between objects.

Sequence

Issue of electronic items

Weather Station Data Collection Sequence

Characteristics of OOD

Objects are abstractions of real-world or system entities and manage themselves Objects are independent and encapsulate state and representation information. System functionality is expressed in terms of object services

Characteristics of OOD (Contd.)

Shared data areas are eliminated Objects communicate by message passing

Objects may be distributed


Objects may execute sequentially or in parallel

Advantages of OOD
Easier

maintenance. Objects may be understood as stand-alone entities are appropriate reusable components some systems, there may be an obvious mapping from real world entities to system objects

Objects

For

Das könnte Ihnen auch gefallen