ICloneable Prototype Template Template

I study design patterns. Today I read about Prototype DP and found that it is used to clone an object. Since we have an ICloneable .Net interface , do we need Prototype DP? Or is ICloneable implementing Prototype DP? Any recommendations for choosing between them?

+6
c # design-patterns prototype-pattern
source share
2 answers

Using only an interface, such as ICloneable , does not mean that you are following the pattern, it all depends on the intention that you are trying to achieve. It's a little philosophical if you do, but I just want to be sure of that. Templates have the power and intention and, by definition, are a common solution to a common problem.

In this specific example, yes, by correctly implementing the interface, you can lead to the intention of the template, because the wikipedia article uses the ICloneable interface for its exameple, written in Java: http://en.wikipedia.org/wiki/Prototype_pattern . Of course, you can use a different approach using your other interface, it is not a requirement for the template to use the ICloneable interface.

Hope this helps and welcomes the world of models :)

+9
source share

Design patterns are not something that is inherent in the language, but they are a common solution to a common problem. They are a concept and can be implemented in various ways and in different languages.

+4
source share

All Articles