UML

κ°μ²΄μ‚¬μ΄μ˜ κ΄€κ³„μ •μ˜

클래슀 관계 μ’…λ₯˜

μΌλ°˜ν™” (Generalization)

  • 일반적으둜 상속 (Inheritance) 관계λ₯Ό μ •μ˜ν•  λ•Œ μ‚¬μš©
  • λΆ€λͺ¨ - μžμ‹ 관계λ₯Ό λ‚˜νƒ€λ‚΄μ–΄ 슈퍼 클래슀λ₯Ό μ„œλΈŒ 클래슀둜 ꡬ체화 (Specialize) ν•˜λŠ” 것이닀.
  • 슈퍼 ν΄λž˜μŠ€κ°€ 좔상 클래슀인 경우 λ©”μ„œλ“œ κ΅¬ν˜„μ‹œ μ˜€λ²„λΌμ΄λ”© ν•  ν•„μš”κ°€ μžˆλ‹€.
public class User {
  private String id;
  private String password;

  public void login() {
    /* 일반 μ‚¬μš©μžμ˜ 둜그인 */
  }
}
public class Customer extends User {
 @Override
  public void login() {
    /* Customer 의 둜그인 */
  }
}
public class Admin extends User {
  @Override
  public void login() {
    /* κ΄€λ¦¬μžμ˜ 둜그인 */
  }
}

싀체화 (Realization)

  • μΈν„°νŽ˜μ΄μŠ€ (interface) 의 λͺ…μ„Έ ν˜Ήμ€ μ •μ˜ (spec) 만 μžˆλŠ” λ©”μ„œλ“œλ₯Ό μ˜€λ²„λΌμ΄λ”©ν•˜μ—¬ μ‹€μ œ κΈ°λŠ₯으둜 κ΅¬ν˜„ ν•˜λŠ”κ²ƒμ„ λ§ν•œλ‹€.
  • μΈν„°νŽ˜μ΄μŠ€ (interface) λ₯Ό κ΅¬ν˜„ (implementation) ν•˜λŠ” ν˜•νƒœ
public interface CheckLogic {
  public boolean isTrue();
}
public class DateCheckLogin implements CheckLogic {
  @Override
  public boolean isTrue() {
    return true;
  }
}

μ˜μ‘΄ν™” (Dependency)

  • ν΄λž˜μŠ€λ“€ κ°„μ˜ κ°€μž₯ μ•½ν•œ κ΄€κ³„μœ ν˜•
  • μ–΄λ–€ ν΄λž˜μŠ€κ°€ νŠΉμ • 클래슀λ₯Ό μ°Έμ‘°ν•˜λŠ” 것을 λ§ν•œλ‹€.
public class User {
  public Schedual createSchdule() {
    return new Schedule();
  }

  public void useSchedule(Schedule schedule) {
    Schedule schedule(2019) = schedule.getScheduleByYear(2019);
  }
}

참고자료

http://www.nextree.co.kr/p6753/