views:

61

answers:

1

i know that you can create your own design patterns and save them for later use.

but i wonder if there are free templates you can download and use, eg. factory, singleton and so on.

then you dont have to recreate/copy-paste and you will have accurate patterns.

+2  A: 

You seem to have misunderstood the concept of a pattern. If patterns were ment to be used as you describe, than there would be plenty of libraries and frameworks providing many patterns and their different implementations, however, there are not. Why is it like that? The reason is, that patterns are not bound to any implementation, they are just design concepts. Take for example Singleton, Factory Method, Facade and Decorator, those are four different design patterns from the original GoF book, however, they can be represented by single one object! That might be not so trivial to implement in a generic way, but I think you can imagine implementing something that should be single place for creating certain objects while grouping some delegated operations and adding some new ones. Those things are hard and even sometimes impossible to implement generically in most languages and therefore there are books with patterns - pattern catalogs. Those books contain descriptions of the patterns, their trade-off and design trivia and also some simple implementation for presentation purposes. Bear in mind, patterns are not algorithms nor data structures, nor libraries nor frameworks.

Gabriel Ščerbák