简体   繁体   中英

Replace constructor with a factory/or a builder

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

-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?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM