开发者

Replace constructor with a factory/or a builder

开发者 https://www.devze.com 2023-02-04 10:48 出处:网络
I am using IntelliJ 10 Comnunity Edition, and I noticed there are two refactoring options which are similar:

I am using IntelliJ 10 Comnunity Edition, and I noticed there are two refactoring options which are similar:

开发者_如何学JAVA

-Replace constructor with factory -Replace constructor with builder

What are the differences between these two? When would I want to use over another?

Thanks


Use constructors to build an object when it can satisfy all the invariants. To understand the difference between builder and factory look this post What is the difference between Builder Design pattern and Factory Design pattern?

0

精彩评论

暂无评论...
验证码 换一张
取 消