Lecture 8 UML(Unified Modeling Language) (II) Prof. Dae-Hyun Lee, Ph.D Dept. of Game Engineering Korea Polytechnic University
학습목차 Sequence Diagram Communication Diagram Activity Diagram State Diagram Component Diagram Deployment Diagram
Sequence Diagram Captures dynamic behavior (time-oriented)
시퀀스다이어그램 (Sequence Diagram) 여러객체들이다른객체들과교류하는메커니즘을보여줌. 시간의개념이도입됨. Typically used to show the detail of a single use case. Show the objects involved in a single scenario, and the messages passed between them
시퀀스다이어그램구성요소
시퀀스다이어그램을이용한유스케이스씨나리오모델링 먼저클래스다이어그램을도출한다 :
정상적인케이스의씨나리오
음료수가떨어졌을때의씨나리오
거스름돈이필요한경우의씨나리오
일반시퀀스다이어그램 (General Sequence Diagram) 지금까지는하나의씨나리오만그려봤음 인스턴스시퀀스다이어그램 하나의시퀀스다이어그램에여러개의씨나리오를포함시킨것이일반시퀀스다이어그램임. 전이조건 [ 전이조건 ] 으로표시. 씨나리오의종료 <<transaction over>> 로표시.
시퀀스다이어그램내에서객체의생성
시퀀스다이어그램내에서객체의소멸
Communication Diagram Captures dynamic behavior (message-oriented) Purpose Model flow of control Illustrate coordination of object structure and control
통신다이어그램 (Communication Diagram) UML 1.x 에서는협력다이어그램 (Collaboration Diagram) 시퀀스다이어그램과마찬가지로객체들사이의교류를보여줌. 차이점 시퀀스다이어그램 객체간의교류를시간의순서에초점을두어나타냄. 시간에따라배열. 통신다이어그램 객체들의전체적인조직과상황에초점. 공간상에배열.
통신다이어그램의구성 Object sequence no.: message link direction arrow
Numbering Scheme Simple Numbering Scheme :Order entry Window 1: prepare( ) :Order 2*: prepare( ) 3: check( ) 4: [check == true] remove( ) 5 : needtoreorder( ) Macallan line : Order Line Macallan stock : Stock Item 7: [check == true] new 6: new :Delivery Item :Reorder Item
Numbering Scheme Decimal Scheme :Order entry Window 1: prepare( ) :Order 1.1.2.1 : needtoreorder( ) 1.1*: prepare( ) 1.1.1: check( ) 1.1.2: [check == true] remove( ) Macallan line : Order Line Macallan stock : Stock Item 1.1.3: [check == true] new 1.1.2.2: new :Delivery Item :Reorder Item
자판기판매정상씨나리오의통신다이어그램 (1)
자판기판매정상씨나리오의통신다이어그램 (2)
여러객체로메시지전송
반환된결과나타내기
활성객체 활성객체 객체간의교류흐름을제어하는객체로써, 수동객체에게메시지를보내며다른활성객체들과교류한다. 두꺼운경계선사각형으로표시.
실습과제 #8 Tetris 게임의시퀀스다이어그램그리기 게임핵심메카닉에대해서만 랜덤하게블록이생성되고, 사용자의입력에따라좌우이동, 회전, 또는바닥으로떨어진다. 바닥이꽉차면지워진다. 수업직후 1-Page 제출 제목 : 2008 GSE 실습과제 (8) 학번이름
상태다이어그램 (State Diagram) Captures dynamic behavior (event-oriented) Purpose Model object lifecycle Model reactive objects (user interfaces, devices, etc.) 시스템의변화를모델링하는다이어그램. 사건이나시간에따라시스템내의객체들이자신의상태 (state) 를바꾸는과정을모델링함. 분석가, 설계자, 개발자들이시스템내의객체의행동을이해하는데큰도움을줌. Modeling, specification 및 implementation 에모두사용되는강력한툴 상태 (state) 의변화예 스위치를누를때마다탁상전등상태는 켜짐 에서 꺼짐 으로바뀐다. 리모트컨트롤의버튼을누르면 TV 의상태는한채널을보여주다가다른상태를보여주게된다. 얼마간의시간이흐르면세탁기의상태는 세탁 에서 헹굼 으로바뀐다.
게임상태 (Game State) 의이해 (1) 게임상태란? 게임프로그램실행중의어떤특정위치 ( 또는모드 ). 사용자입력 ( 키보드또는마우스입력 ) 에대한대응방식은게임의상태에따라달라짐. 맵선택상태. 방향키는맵선택을처리. 게임메인플레이상태.. 방향키는캐릭터의이동을처리.
게임상태 (Game State) 의이해 (2) 게임프로그램은게임상태의집합으로구현됨. 예 ) 테트리스게임
게임상태 (Game State) 의이해 (3) 플레이모드내에서도게임상태의세분화가가능 가능하면작은단위의게임상태로세분화할수록개발및디버깅이용이. 예 ) 테니스경기에서서브상태와스트로크상태의구분. 서브상태. O 버튼은서브동작. 스크로크상태. O 버튼은스트로크동작.
State A state is a condition in which an object can reside during its lifetime while it satisfies some condition, performs an activity, or waits for an event. An entry action is the first thing that occurs each time an object enters a particular state. An exit action is the last thing that occurs each time an object leaves a particular state. A do activity is an interruptible sequence of actions that an object can perform while it resides in a given state. (Actions are not interruptible.)
Transition( 전이 ) A transition is a relationship between two states; it indicates that an object in the first state will perform certain actions, then enter the second state when a given event occurs. Event( 사건 ) transition 은 event 에의해서발생 triggerless transition 현재상태의활동이종료된후다음상태로이전하는것.
Guarded transitions( 조건전이 ) A transition may be qualified by a guard condition The transition does not take place if the guard evaluates to FALSE A guard condition can be any Boolean expression
복합상태 (Composite States) 순차적하위상태 (Sequential substates) 동시적하위상태 (Concurrent substates)
History States( 이력상태 ) 주어진객체가복합상태를벗어날때, 활성중인하위상태를기억하게함을나타냄.
전화기의상태다이어그램
계속변경이필요한상태머신이필요하면? 상태다이어그램보다는엑셀과같은프로그램을이용하여, 상태전이테이블 (State Transition Table) 을이용하는것이편리하다.
Activity Diagram Activity diagrams describe how activities are coordinated. For example, an activity diagram may be used (like an interaction diagram) to show how an operation could be implemented An activity diagram is particularly useful when you know that an operation has to achieve a number of different things, and you want to model what the essential dependencies between them are, before you decide in what order to do them Can be used to analyze use cases Activity diagrams are much better at showing this clearly than interaction diagrams. 36
Differences between activity diagrams and state diagrams Activity diagrams do not normally include events Activity is intended to proceed, following the flow described by diagram, without getting stuck 38
State Diagram Carryovers The following items are common to state diagrams and activity diagrams: activities actions transitions initial/final states guard conditions Bid plan Do construction entry/setlock()
Breaking Up Flows Alternate paths: branch merge Parallel flows: fork join
Branching A branch has one incoming transition and two or more outgoing transitions: Charge credit card [today > 7 days before show] [today < 7 days before show] Mail tickets Hold in will-call
Merging A merge has two or more incoming transitions and one outgoing transition: Mail tickets Customer picks up tickets Customer sees show
Forking A fork represents the splitting of a single flow of control into two or more concurrent flows of control: Receive order Log order Process order
Joining A join represents the synchronization of two or more flows of control into one sequential flow of control: Receive product Bill customer Pay bill
신호의전송과수신 활동이진행되는도중에신호를주고받을수있음.
비즈니스로직의활동다이어그램
구획면 (Swimlanes)
활동다이어그램과시퀀스다이어그램의결합
컴포넌트다이어그램 (Component Diagram) Component 시스템을이루는물리적요소 시스템의기능을정의하며, 한개이상의클래스를구현하여하나의컴포넌트를만든다. A component diagram shows the dependencies among software components e.g. software modules Captures the physical structure of the implementation
Component Diagram Captures the physical structure of the implementation Built as part of architectural specification Purpose Organize source code Construct an executable release Specify a physical database Developed by architects and programmers
컴포넌트간의관계를모델링하는이유 의뢰인이완성된시스템의구조와완성된시스템의기능을볼수있게하기위해 개발자에게작업할구조를구체적으로알리기위해 문서와도움말을제공해야하는문서화담당자들이쉽게이해할수있도록하기위해 컴포넌트를언제든지재사용할수있게하기위해
컴포넌트의표현
인공물과컴포넌트사이의관계표시
컴포넌트와인터페이스의관계표시
Deployment Diagram Shows the physical relationships among software and hardware components in the delivered system
Deployment Diagram Built as part of architectural specification Purpose Specify the distribution of components Identify performance bottlenecks Developed by architects, networking engineers, and system engineers
노드 (Node) Each node on a deployment diagram represents some kind of computational unit, usually a piece of hardware. The hardware may be a simple device or sensor, or it may be a mainframe.
인공물배포모델링
Example deployment diagram node connection contained object component dependency
홈네트워크시스템
UML 사용팁 Use case diagram to gather and explore requirements Activity diagram to explore the scenarios of use cases Class diagram to identify classes and see how classes relate to each other Object diagram to see how one object communicates with each other State chart diagram to explore how the attributes of an object change
Sequence diagram to fully explore a use case by tracing the order in which objects send messages to themselves or each other Collaboration diagram to view the logic of the system and the way that objects send messages to each other Component diagram to explore whether and how subsystems exist within your game product Deployment diagram to figure out how to set up the installation package for your game
실습과제 #9 Tetris 게임의코딩 Tetris 게임의클래스다이어그램및시퀀스다이어그램으로부터, C++ 코드작성. Visual C++ 이용, 단일파일 (main.cpp) 로작성. 게임은무한루프진행. 블록지우는기능은없음. 보드의높이는 20 으로설정. 키입력은랜덤하게생성 블록은 left key, right key, up key, space key, no key L, O,, T 출력은텍스트로만. 새블록 L 생성 left 키입력 : L 블록왼쪽이동 Right 키입력 : L 블록오른쪽이동 No 입력 : L 블록아래쪽이동 Space 키입력 : L 블록다운 새블록 생성 수업직후제출 제목 : 2008 GSE 실습과제 (9) 학번이름 main.cpp 를첨부파일로제출. 평가포인트 클래스다이어그램및시퀀스다이어그램과의일치성.
참고클래스다이어그램 InputManager Board GameManager Block Block Generator 테테테테테테 테테테테테테 테테테테테테
참고시퀀스다이어그램 : GameManager : Block Generator : Board : InputManager : Player loop Game Main [key!= ESE] 1 : gamestart() 2 : createblock() : Block <<create>> 3 4 : inserblock() 5 : input = getinput() 6 [input = left] : moveleftactiveblock() 8 [input = right] : moverightactiveblock() 7 : moveleft() 9 : moveright() 10 [input = space] : : dropactiveblock() 12 : updateboard() 11 : movedrop() 13 : draw()