개발/개념

    [객체지향] SOLID 예제(5) - 인터페이스 분리의 원칙(ISP)

    interface IPerson { wakeUp(): void; bathroomActivity(): void; } class Person implements IPerson { private bathroom: IBathroom; constructor(bathroom: IBathroom) { this.bathroom = bathroom; } wakeUp() { console.log('아침에 일어난다.'); } bathroomActivity() { this.bathroom.goToBathroom(); this.bathroom.washFace(); this.bathroom.brushTeeth(); this.bathroom.washHair(); this.bathroom.dryOff(); this.bathroom...

    [객체지향] SOLID 예제(4) - 리스코프 치환의 원칙(LSP)

    interface IPerson { wakeUp(): void; bathroomActivity(): void; } class Person implements IPerson { private bathroom: IBathroom; constructor(bathroom: IBathroom) { this.bathroom = bathroom; } wakeUp() { console.log('아침에 일어난다.'); } bathroomActivity() { this.bathroom.goToBathroom(); this.bathroom.washFace(); this.bathroom.brushTeeth(); this.bathroom.washHair(); this.bathroom.dryOff(); this.bathroom...

    [객체지향] SOLID 예제(3) - 개방-폐쇄의 원칙(OCP)

    class Person { private bathroom: Bathroom; constructor(bathroom: Bathroom) { this.bathroom = bathroom; } wakeUp() { console.log('아침에 일어난다.'); } bathroomActivity() { this.bathroom.goToBathroom(); this.bathroom.washFace(); this.bathroom.brushTeeth(); this.bathroom.washHair(); this.bathroom.dryOff(); this.bathroom.leaveBathroom(); } } class Bathroom { goToBathroom() { console.log('화장실로 간다.'); } was..

    [객체지향] SOLID 예제(2) - 의존성 역전의 원칙(DIP)

    class Person { private bathroom: Bathroom; constructor() { this.bathroom = new Bathroom(); } wakeUp() { console.log('아침에 일어난다.'); } bathroomActivity() { this.bathroom.goToBathroom(); this.bathroom.washFace(); this.bathroom.brushTeeth(); this.bathroom.washHair(); this.bathroom.dryOff(); this.bathroom.leaveBathroom(); } } class Bathroom { goToBathroom() { console.log('화장실로 간다.'); } washFace() { co..