Builder design pattern: Why do we need a Director?

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

    Let's say that you want to make a cake without the dry ingredients. What you are going to do is just adding a new method into the Director or making another Director. This will protect you from inheritance complexity and also will make your code more flexible.

提交回复
热议问题