Builder design pattern: Why do we need a Director?

后端 未结 7 1970
梦如初夏
梦如初夏 2020-12-13 18:10

Recently I\'ve come across the Builder design pattern. It seems that different authors use \"Builder pattern\" to refer to different flavours, so let me describe the pattern

7条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-13 18:15

    I agree with you. I think that the other approach is that the CakeBaker should have a GetCake() method which returns a cake(Cake class) and MakeCake() method where the algorithm will run. That's fine but on other hand there is a responsible separation there. Consider abstract builder and specific bulders as builders of a cake parts only and Director as manager or designer whose responsibility is to assemble and produce a cake.

提交回复
热议问题