Builder design pattern: Why do we need a Director?

后端 未结 7 1963
梦如初夏
梦如初夏 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:33

    Downside of patterns is that they pollute our understanding of business domain with technical terms and blurs our focus.

    As I see it - there is too much coupling in between cake and knowledge of how to make it. Those can be decoupled by introducing an idea of cake having a recipe in our code (more like borrowing from real world, designing our model by business domain). Recipe would have ingredients and baking steps (just a step name, not actual implementation because recipes don't bake cakes) on how to make cake what recipe describes. Our baker would have a method BakeCake(recipe), and bunch of smaller methods according to baking steps like mix, add ingredient, etc.

    Be aware that if you would need to model chef in general, not just cake baker, you would also need to decouple knowledge of making bakes from baker itself too. It could be done by introducing idea of chef having a skill.

    0 讨论(0)
提交回复
热议问题