• 검색 결과가 없습니다.

Object-oriented design

N/A
N/A
Protected

Academic year: 2022

Share "Object-oriented design"

Copied!
29
0
0

로드 중.... (전체 텍스트 보기)

전체 글

(1)

Formalisms for system design

aSystem design performs many design tasks at different levels of abstraction

`Requirements, Specifications, Architecture, Coding, Testingg, g

aIt is helpful to conceptualize these tasks in diagrams

in diagrams

`Unified Modeling Language (UML), a visual language is useful because it encourages

language is useful because it encourages

design by successive refinement to the design

(2)

S t d li

System modeling

aNeed languages to describe systems:

`useful across several levels of abstraction;

`understandable within and between organizations.

aBlock diagrams are a start but don’t aBlock diagrams are a start, but don t

cover everything.

(3)

Obj t i t d d i

Object-oriented design

aObject-oriented (OO) design: A li ti f bj t i t d generalization of object-oriented programming.

aObject = state + methods.

`State provides each object with its own

`State provides each object with its own identity.

`M th d id b t t i t f t th

`Methods provide an abstract interface to the object.

(4)

Obj t d l

Objects and classes

aClass: object type.

aClass defines the object’s state elements but state values may change over time.y g aClass defines the methods used to

interact with all objects of that type interact with all objects of that type.

`Each object has its own state.

(5)

OO d i i i l

OO design principles

aSome objects will closely correspond to real world objects

real-world objects.

`Some objects may be useful only for description or implementation

description or implementation.

`Environment (the outside world): people or other machine

other machine

aObjects provide interfaces to read/write t t hidi th bj t’ i l t ti

state, hiding the object’s implementation from the rest of the system.

(6)

UML UML

aDeveloped by Booch et al.

aGoals:

`object-oriented;

`object oriented;

`visual;

`useful at many levels of abstraction;

`useful at many levels of abstraction;

`usable for all aspects of design.

(7)

UML bj t UML object

object name d1 Di l

object name

class name d1: Display

pixels: array[] of pixels pixels is a pixels: array[] of pixels

elements menu items pixels is a

2-D array

menu_items

comment

attributes

(8)

UML l

UML class

Display Class name

pixels elements

pixels is a elements A ib

menu_items pixels is a

2-D array Attribute

mouse_click()

d b Operations

draw_box Operations

(9)

Th l i t f

The class interface

aThe operations provide the abstract

i t f b t th l ’

interface between the class’s

implementation and other classes.

aOperations may have arguments, return values

values.

aAn operation can examine and/or modify the object’s state.

(10)

Choose your interface l

properly

aIf the interface is too small/specialized:

`object is hard to use for even one application;

`object is hard to use for even one application;

`even harder to reuse.

aIf th i t f i t l

aIf the interface is too large:

`class becomes too cumbersome for designers to

d t d

understand;

`implementation may be too slow;

d l b bl b

`spec and implementation are probably buggy.

(11)

Relationships between bj t d l

objects and classes

aAssociation: objects communicate but one

d t th th

does not own the other.

aAggregation: a complex object is made of gg g p j several smaller objects.

aComposition: aggregation in which owner aComposition: aggregation in which owner

does not allow access to its components.

aGeneralization: define one class in terms of another.

of another.

(12)

Cl d i ti

Class derivation

aMay want to define one class in terms of th

another.

`Derived class inherits attributes, operations of base class.

Derived_class

li ti Base_class

generalization

(13)

Cl d i ti l Class derivation example

Display pixels elements

menu_items Base class

pixel()

set_pixel()

li k() mouse_click() draw_box

BW_display Color_map_display

(14)

M lti l i h it

Multiple inheritance

Base class

Speaker Display

M lti di di l D i d l Multimedia_display Derived class

(15)

Li k d i ti

Links and associations

aLink: describes relationships between bj t

objects.

aAssociation: describes relationship p between classes.

(16)

Li k l Link example

aLink defines the contains relationship:

message

msg = msg1 length = 1102

message set count = 2 message

count = 2 msg = msg2

length = 2114

(17)

A i ti l Association example

# contained messages # containing message sets

message message set

0..* 1

msg: ADPCM_stream

length : integer contains count : integer

(18)

St t

Stereotypes

aStereotype: recurring combination of

l t i bj t l

elements in an object or class.

aExample:p

`<<signal>> in Fig 1.11

(19)

B h i l d i ti

Behavioral description

aSeveral ways to describe behavior:

`internal view;

`external view.

(20)

St t hi

State machines

transition

a b

transition

a b

state state name

(21)

Event-driven state hi

machines

aBehavioral descriptions are written as

t d i t t hi

event-driven state machines.

`Machine changes state when receiving an input.

aAn event may come from inside or outside aAn event may come from inside or outside

of the system.

(22)

T f t Types of events

aThree types of event defined by UML aSignal: asynchronous event.

aCall: synchronized communication aCall: synchronized communication.

aTimer: activated by time.

(23)

Si l t Signal event

<<signal>>

<<signal>>

mouse_click a

leftorright: button

x, y: position mouse_click(x,y,button)

Signal event declaration b

event description

(24)

C ll t Call event

draw box(10 5 3 2 blue)

c d

draw_box(10,5,3,2,blue)

c d

(25)

Ti t Timer event

e f

tm(time-value)

e f

(26)

E l t t hi

Example state machine

start

mouse_click(x,y,button)/

input/output

region = menu/

hi h (i)

region got menu called

find_region(region) which_menu(i) call_menu(I)

found item menu item

region = drawing/

found object

find_object(objid) highlight(objid)

object highlighted

(27)

S di

Sequence diagram

aShows sequence of operations over time.

aRelates behaviors of multiple objects.

aDesigned to show a particular scenario or aDesigned to show a particular scenario or

choice of events

(28)

S di

Sequence diagram

m: Mouse d1: Display u: Menu

Object

m: Mouse d1: Display u: Menu

mouse click(x,y,button)_ ( ,y, )

which_menu(x,y,i)

Focus of control

call menu(i)

time call_menu(i)

(29)

S

Summary

aObject-oriented design helps us organize d i

a design.

aUML is a transportable system design p y g language.

`Provides structural and behavioral description

`Provides structural and behavioral description primitives.

참조

관련 문서

Three different types of gate design, finger, tangential and split type, were used and the results showed that sound thin-walled die casting was possible with tangential and split

Therefore, in order to design and implement a technical architecture that satisfies the requirements for speed improvement of autonomous vehicles, it is necessary to consider

This study should lay the foundation of different job analysis and the customized curriculums accordingly for not only furniture design coordinator, also for various furniture

Intelligental form parkin g system is designed specific structure architecture for effective improvement of parking space and medical service system propose a

For these requirements, we have designed the layered architecture pattern and applied several design patterns to enhance the reusability and the maintainability

In order to support rapid prototyping, the proposed system provides testing and management tools for IoT sensor nodes.. We analyze the requirements of the proposed system and