코드로 UML 클래스 연결 설명

3965 단어 uml
UML 클래스 다이어그램의 관계에 대한 간단한 참고 사항입니다.

관계 및 종속성





이렇게 TS코드로 변환 가능

class Address {}

class Food {}

class People {
  // for this line People has relation with Address 
  address: Address
  heart: Heart

  // for this line People has dependency with Food
  eat(food: Food) {}
}


집계 및 구성





이렇게 TS코드로 변환 가능

class Heart {}

class People {
  heart: Heart

  constructor () {
    // for this line People has composition with Heart
    this.heart = new Heart()
  }
}

class PeopleGroup {
  peoples: People[]

  // for this line PeopleGroup has aggregation with (alot of) People
  constructor (peoples: People[]) {
    this.peoples = peoples
  }
}


일반화 및 실현





이렇게 TS코드로 변환 가능

class Animal {}

interface Eatting {
  eat(food: Food): void
}

class People 
  // for this line People is extends (generalization) from Animal
  extends Animal
  // for this line People is implement (realization) from Eatting
  implements Eatting {
  // ...
}

좋은 웹페이지 즐겨찾기