• Category: creational
  • Type: class
  • Motivation: make product and operate product

do {
  let manager = DevelopmentManager()
  manager.takeInterview()
}
protocol Interviewer
{
    func askQuetions()
}

class Developer: Interviewer
{
    func askQuetions()
    {
        print("Asking about design patterns")
    }
}

protocol HiringManager
{
    func makeInterviewer() -> Interviewer
    // Factory Methods
    func takeInterview()
}

class DevelopmentManager: HiringManager
{
    func makeInterviewer() -> Interviewer
    {
        return Developer()
    }

    func takeInterview()
    {
        let interviewer = makeInterviewer()
        interviewer.askQuetions()
    }
}