• Category: behavioral
  • Type: class
  • Motivation: define the skeleton of how a certain algorithm could be preformed, but defers the implementation of those steps to the children classes

diagram

do {
    let builder = SwiftBuilder()
    builder.build()
}
protocol Builder
{
    func build()

    func test()
    func lint()
    func assemble()
    func deploy()
}

extension Builder
{
    func build()
    {
        test()
        lint()
        assemble()
        deploy()
    }
}
class SwiftBuilder: Builder
{
    func test() {
        print("swift test")
    }

    func lint()
    {
        print("swift lint")
    }

    func assemble()
    {
        print("swift assemble")
    }

    func deploy()
    {
        print("swift deploy")
    }

}