HypeDitto / iOS-Study

iOS 기술 면접 대비
0 stars 0 forks source link

의존성 주입에 대하여 설명하시오. #89

Open YouHojoon opened 1 year ago

YouHojoon commented 1 year ago

장점

class Programmer {
    private coffee: Coffee

    // 그 날 마실 커피를 고를 수 있게된 개발자
    init(coffee: Coffe) {
        self.coffee = coffee
    }

    func startProgramming() {
        coffee.drink()
        ...
    }
}