Design Pattern: Builder

前端 未结 4 2012
粉色の甜心
粉色の甜心 2020-12-14 07:43

I have looked for a good example of a Builder pattern (in C#), but cannot find one either because I don\'t understand the Builder pattern o

4条回答
  •  执笔经年
    2020-12-14 08:15

    I would say that you cannot avoid either of these - having few overloads for your parts and having a case/if statement somewhere down the stack. Also having to modify your code when adding new class might be your only option.

    That being said you can get help with some other patters - namely Factory that could aid you in the building process. Also sensible use of polymorphism (e.g. all parts inherit from the some type be it class or interface) can reduce the amount of ifs/cases and overloads.

    Hope this helps.

提交回复
热议问题