Java – replace constructors with factories and / or builders

I'm using IntelliJ 10 comunity edition, and I notice two similar refactoring options:

– replace constructor with factory – replace constructor with builder

What's the difference between the two? When do I want to use another one?

thank you

Solution

When the constructor satisfies all invariants, you can use the constructor to build objects To understand the difference between a builder and a factory, check out this post. What is the difference between Builder Design Pattern and factory design pattern?

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>