본문 바로가기
SW 공부/OOP_OOAD_UML

[UML] Class Diagram

by 꼬냉상 2022. 8. 29.

Class Diagrams 

- static structure를 그릴 때 사용

- The same UML class diagrams can be used in multiple perspectives.

   * In a conceptual perspective, Domain model - OOA
      : 간단하게

 

    * In a design perspective, Design Class Diagram (DCD) -OOD
    : 구현될 때, Design Model

code Generation 수준으로 

 

Object

- Object Diagram :특정 시점의 관계를 표시

- Object name은 소문자로 시작

- obeject들의 관계는 링크를 연결해서 표시

 

From Object to Class

- A class is a construction plan for a set of similar objects of a system. 
  – Objects are instances of classes.
•  Attributes: structural characteristics of a class
  – Different value for each instance (object)
•  Operations: behavior of a class
  – Identical for all objects of a class
    → not depicted in object diagram

 

 

 

Attribute syntax (Notation)

- Visibility : Who is permitted to access the attribute.

    + ... public: everybody
     - ... private: only the object itself
     # ... protected: class itself and subclasses
     ~ ... package: classes that are in the same package

- Derived Attribute  '/' : 밖에서 들어와서 계산되는 것 (추출해서 넣은 것)

- Name : 소문자로 시작

- Type : Data types  (Primitive data type / Enumerations) , User-defined classes

- Multiplicity : Number of values which an attribute may contain  ( Default value: 1) 
    Notation: [min..max]

- Properties : 정보를 적어놓는다는 개념

 

Operation syntax (Notation)

- Parameters : in … input parameter / out … output parameter / inout : combined input/output parameter

- Type

 

Operations and Methods

- Operation (선언)과 Method(구현 코드)는 구분할 필요가 있다. 

- OOAD에서는 상세 구현을 하지 않기 때문에 Operation만 선언해두자!

- Implement Result인 Method는 똑같은 operation을 보고 구현하더라도 c++, java 언어에 따라, 개발하는 사람에 따라 다를 수 있다.

 

Class Variable and Operation

- Class variable (= class attribute, static attribute)

- Class operation (= static operation)

→ Class에서만 사용되는 variable / operation 은 static으로 구현 (밑줄이 그어진 것)

 

Operations to Access Attributes in DCDs

- getter / setter  함수 

- OOAD에서는 상세 구현을 하지 않기 때문에 Operation만 선언해두자!

- class의 private variable은 +getter 함수가 있어서  Access가 가능해짐

 

Note Symbols

- 접은 표시 있는 박스, note or comment 

→ <<method>> Method body로 수도 코드나 구현을 남겨둘 수 있음 

 

Class Relationship

- Dependency : 잠깐 일하고 안 하는 경우의 관계. 주로 Component diagram에 나오고, 구현 단계에서는 잘 안 나옴.

-  Association : 일정 시간 동안 일하는 object가 있는 class들을 연결

- Aggregation : reference로 쓰고 있어서 한쪽이 삭제돼도 영향이 X  

 

← 여기서 LabClass가 0 일 수 있음 

LabClass가 사라져도 Student는 사라지지 않음

 

 

 

 

 

- Composition : 강화된 aggregation.  dipendency가 있음. Compoenet object and it's part and its parent.

 

← A 쪽이  end/ B가 Head

- Composite object (B)가 삭제되면 parent(A)도 삭제되어야 함

 

- Inheritance :  상속. 내려받는 것~! (초강력)

 

Quiz) Class에 대한 다음의 설명 중 올바르지 않은 것은?
① Attribute의 default visibility는 (-) : Private이다.
② Operation의 default visibility는 (+) : Public이다.
③ 모든 Private Attribute에 대해서는 getter와 setter operations을 항상 만들어야 한다.
④ 모든 Attributes과 Operations은 Visibility(+/-)가 항상 표시되어야 한다.

 

Quiz) Generalization (Inheritance)에 대한 다음의 설명 중 올바르지 않은 것은?
① Everything of a general class are passed on to its subclasses.
→ General Class(parent)의 public만 SubClass(Child) 에게 전달됨.

② Every instance of a subclass is simultaneously an indirect instance of the superclass.
③ Subclass inherits all characteristics (attributes and operations), associations, and aggregations of the superclass except private ones.

④ Subclass may have further characteristics, associations, and aggregations.

 

Quiz) 다음 Class Diagram의 정보를 가장 잘 해석한 것은?

① 모든 책은 그림과 챕터로 구성될 수 있다.
② 대부분의 책은 그림으로 구성되어 있지만 일부는 챕터로 구성된다.
③ 대부분의 책은 챕터로 구성되어 있지만 일부는 그림으로 구성된다.
④ 모든 책은 그림과 챕터로 구성되어야 한다.
⑤ 책과 그림과 챕터는 다 동등한 개념이다.

 

본 글은 개인의 S/W 구조설계 역량 강화를 위한 학습 목적으로 정리된 내용입니다.
일부 타/개인 단체에 저작권이 있는 자료를 포함하고 있으므로, 절대 영리 목적으로 사용하실 수 없습니다.
반응형

'SW 공부 > OOP_OOAD_UML' 카테고리의 다른 글

[UML] Statechart Diagram  (0) 2022.08.29
[UML] Sequence Diagram  (0) 2022.08.29
[UML] Use Case Diagram  (0) 2022.08.29
[UML] 13개의 UML Diagrams 소개  (0) 2022.08.29
[OOP] 3. Object-Oriented Development (객체지향 개발론)  (0) 2022.08.29

댓글