I am a beginner in Java and the book that I use to learn it seems to have cryptic examples and sentences that completely confuse me.
I understand what interfaces are and how/where to apply the concept in real world. But what are Factory Methods? The term "factory method" is ambiguous (JavaScript has a different meaning for that) so I am providing the snippet that the book has, in order to make my question clear. Here is the code:
interface Service {
void method1();
void method2();
}
interface ServiceFactory {
Service getService();
}
The Service
interface is just a normal interface. ServiceFactory
interface looks like a normal interface but it is a "Factory Method". What's that? What does it solve and why I should use them?
Aucun commentaire:
Enregistrer un commentaire