建筑设计模式的缺点 [英] disadvantages of builder design pattern
问题描述
编辑 - 我想知道使用构建器设计模式是否有任何不良后果?在GOF的书中,他们提到了设计模式的好坏结果。但是他们没有提到对于构建器设计模式的任何不好的后果。
它确实创建了更多的代码(并且可能会引入更多的复杂性)在DTO中比,如果你有例如参考者和/或设置者/ getter。
在我看来,这并不是一件大事,在大多数情况下没有很多额外的代码。如果您有一个对象具有一些强制性和一些可选参数,那么构建器模式将是非常值得的。
What would be the disadvantages of using the builder design pattern. Are there any??
edit - I want to know whether there is any bad consequence of using builder design pattern? As in the GOF book, they have mentioned the good and bad consequences of design patterns. But they haven't mentioned any bad consequence for builder design pattern.
It does create more code (and could introduce more complexity) in the DTO than if you had for example contructor arguments and/or setters/getters.
In my opinion this is not a big deal, in most cases there is not a lot of extra code. The builder pattern will be more than worth it if you have an object that has some mandatory and some optional parameters.
这篇关于建筑设计模式的缺点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!