• 검색 결과가 없습니다.

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.

참조

관련 문서

(2) 사고의 발생 방지: 방사성 물질을 내장하는 기기 등은 상정되는 운전 조건을 적절하게 고려하여 그 구조 건전성을 확보함과 동시에 내장하는 방사성 물질이

이러한 시대적 흐름에 따라 뮤지컬 퍼포먼스 연계전공을 개설함으로써 영상과 함께하는 뮤지컬 연기의 실습과정을 경험하고 뮤지컬 공연 예 술에 진입하기

- 대구경 보수 port가 필요하고, PF coil 설치 위치에 대한 제약, TF coil의 비틀림 힘에 대한 지지 제약(코일 간 지지 구조물의 설치 영역 제약)의

21세기 미래형 선도 산업으로써 주도적 역할을 담당하고 있는 국내외 호텔 및 전문외식산업 분야에 중추적인 역할을 수행할 진취적이고 도전적인 최고의 글로벌

- Divertor: 중성자와 각종의 하전입자 충돌로 방사화됨. Divertor plate도 교환할 필요가 있음. 예) ITER: cassette 모양의 설계.. 중성자 조사량이 매우 높고,

2009 Fall, Computer Aided Ship Design – Part1 Optimal Ship Design.. @ SDAL Advanced Ship

Design consulting service focusing on design development is dominant in Korean design industry. There has been design consulting service supported by

2009 Fall, Computer Aided Ship Design – Part1 Optimal Ship Design.. @ SDAL Advanced Ship