Code&Data Insights
[JAVA/UML] Class Diagram 본문
분명 자바 수업인데, 교수님은 자꾸 C++이랑 비교하면서 설명해서 헷갈려 돌아버리는 줄 알았다 ㅋㅋㅋ
저번 교수님은 걍 간단하게 상속이랑 access modifier 표기만 짚고 넘어갔는데
이 교수님은 아예 과제도 class diagram 그려오라 그러고 aggregation, compostion 등등 첨 듣는 개념...
근데 어차피 프로그래밍 언어를 막론하고,
UML은 소프트웨어 설계를 하는데 필요하므로 이참에 정리해보려고 한다.
What is UML?
- Unified Modeling Language
- 소프트웨어 시스템을 설계하는 standardized modeling language
[ UML Class Diagrams ]
- Basic UML Class Diagram은
Classes / Compartments / Fields(속성) / Methods / Dependency and Association 등으로 구성 된다.
- UML Class Diagrams are a way to communicate design
-> they are meant to communicate
: relationships between classes ( inheritances, polymorphism )
: operations provided by classes
: the data encapsulated by classes ( encapsulation )
- They don't need to communicate exact implementation details
- Generalization, solid lines(실선) with a closed arrow represent inheritance.
=> Inheritance: Is-A Relationship
- Implementation, dashed lines with closed arrows represent implementation of interfaces
=> interface, body가 없는 method를 오버라이딩하여 실제 기능으로 implements
[ Dependency and Association ]
< Dependency >
=> Dependencies(의존,종속), dashed lines(점선) with open arrows, indicate a Class uses another class
- If you have an association to a type, no other dependency to that type needs to be shown
- return type / argument type / local variable usage create a dependency
< Association >
=> 연관, 직접 연관이 존재(Association / Directed Association) , multiplicity(다중성)을 가짐
ex) 주문 - 결제 : 주문으로 인해 결제 클래스가 실행 됨 ( 주문을 할수도 있고 안 할 수도 있음 )
=> Associations(연관), solid lines(실선) with open arrows indicate a class has an instance of another class.
=> Association has two types: Composition, Aggregation
< Association(type 1) - Aggregation >
- a weak association
- if both Objects can exist independently.
( 각각의 객체들이 독립적으로 존재할 수 있을 때 )
- Many instances of this class are part of this enclosing class
< Association(type 2) - Composition >
- a strong type of Association
- Has - A Relationship
(an instance of one class has a reference to an instance of another class or another instance of the same class.)
(we mostly use new keywords to implement a Has-A relationship in Java)
- Use directed associations when A has a B: A -> B.
- if an object owns another object and another object cannot exist without the owner object. (하나의 객체가 다른 객체를 소유할때, 그리고 다른 객체가 소유된(주인) 객체없이 존재 할 수 없을 때
(the part cannot exist without the whole part)
ex) customer - order: 고객이 없으면 주문도 존재할 수 없음 (Order Class belongs to Customer Class)
- These instances only exist while the enclosing instance exists
- The identifier/visibility should be used to label a directed association
< Property - Multiplicity (다중성) >
=> multiplicity indicates how many objects may participate in the given relationship or the allowable number of instances of the element.
( 다중성은 주어진 관계 혹은 허용되는 인스턴스의 수에 얼마나 많은 객체가 사용되는 지를 나타낸다. )
'Computer Science' 카테고리의 다른 글
What is a Legacy System? [ 레거시 시스템이란? ] (0) | 2022.06.16 |
---|