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);
}
}
μ°Έκ³ μλ£