Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is Prototype an anti pattern? [closed]

When Joshua Bloch mentions that Cloneable interface is broken in Java, why is the Prototype pattern, which uses clone() method to facilitate object creation, not considered an anti-pattern in Java development?

"It's a shame that Cloneable is broken, but it happens." - Joshua Bloch

like image 976
AKS Avatar asked Sep 11 '15 15:09

AKS


1 Answers

No, Prototype is not an antipattern.

Prototype Design Pattern is language-agnostic. It applies to many other object-oriented programming languages, and it has multiple possible implementations.

Although the implementation that was designed into the Java class library is, indeed, broken, it does not mean that the pattern is broken, too. All it means is that if you would like to use this pattern in your design, you should stay away from the built-in support for it, and make your own instead.

like image 149
Sergey Kalinichenko Avatar answered Sep 22 '22 08:09

Sergey Kalinichenko