UML 코드 변환

froajnzd·2023년 4월 26일
0

pattern

목록 보기
3/12

참고링크 https://www.nextree.co.kr/p6753/

UML Diagram

분석 단계

  • Usecase diagram(사용사례 다이어그램)
  • Activity diagram(액티비티 다이어그램) : flowchart와 유사

객체 상호작용

  • Interaction diagram : 객체들이 어떻게 상호작용하는가. Sequence diagram이 많이 사용됨

설계 단계

  • Class diagram : 클래스 간의 상세한 관계

객체들의 동작에 초점

  • State diagram(상태 다이어그램) : 객체가 가지는 여러 다른 상태를 상세화. 상태 사이의 전환

설치 단계

  • Batch diagram(배치 다이어그램) : 모듈들을 어떻게 어디에 설치하여야 하나?

Class Diagram 요소

클래스 사이의 관계

  • 어떤 클래스가 다른 클래스의 일종(a “kind of”) : is-a 관계
  • 두 클래스 사이에 연관이 있을 때
    - 한 클래스가 다른 클래스를 포함(“contain”)
    1. Composition: 포함된 것이 포함하고 있는 클래스의 일부분. 집합개념이 없으면 부분 개념이 없는 것!
    2. Aggregation: 집합(collection) : 한 클래스가 다른 클래스를 사용(“use”). 집합개념이 없어도 부분개념이 살아남는 것!

코드화 방법

  1. 클래스
public class Dialler {
	private Vector digits;
	int nDigits;
    public void digit(int n);
    protected boolean recordDigit(int n);
}

  • 클래스 이름은 대문자, 굵은 글씨체
  • 추상 클래스 이름은 이탤릭체
  • '+' : public
  • '#' : protected
  • '-' : private
  1. 상속. is-a 관계
public class Employee {}
public class SalariedEmployee extends Employee {}
interface ButtonListener {}
public class ButtonDiallerAdapter implements ButtonListener {}
  1. 집합. has-a 관계
  • 집합 Aggregation(흰다이아몬드) : 소속
  • 구성 Composition(검은 다이아몬드)
  • 사용 관계 (점선 화살표) : 의존관계
  1. 참조. has-a 관계
public class Phone {
	private Button itsButtons[15];
}
public class PhoneBook {
	private Vector itsPnos;
}
  1. 합성 관계. deep copy
import java.util.Vector;

public class Addreass implements Cloneable {

	private Vector itslines = new Vector();
    
    public void setLine(int n, String line) {
    	if (n >= itsLines.size())
        	itsLines.setSize(n+1);
        itsLines.setElementAt(line, n);
	}
    
    // 연관된 모든 항목들을 다 클론해준다.
    public Object clone() throws CloneNotSupportedException {
    	Address clone = (Address)super.clone();
        clone.itsLines = (Vector) itsLines.clone();
        return clone;
    }

0개의 댓글