The Singleton Design Pattern
Short Description
The Singleton design pattern allows many parts of a program to share a single resource without … This article discusses this design pattern, shows several …
Website: www.theperlreview.com | Filesize: 440kb
Content
The Singleton Design Pattern
brian d foy
Abstract
The Singleton design pattern allows many parts of a program to share a single resource without having
to work out the details of the sharing themselves. This article discusses this design pattern, shows several
possible implementations, and highlights some Perl modules which use singletons.
1 About design patterns
Design patterns help structure code, although they do not say anything about how to implement it. They
solve problems before we start to write code because they affect the design of programs by recognizing the
possible abstractions in the problem. More than one pattern may apply, and within any pattern, many ways
to implement it.
We typically represent patterns with modules so their implementations are re-usable and abstract and make
full use of encapsulation. The rest of the program does not need to know how the module works, and indeed,
the more the program knows about the module’s workings, the more of a problem we have. Patterns promote
loose coupling so that their implementation does not affect the rest program.
2 When to consider using a singleton
Some things, like a particular hardware interface or serial port, or a software construct such as…
Get the file Download here
Related Books:Related Searches: hardware interface, structure code, design patterns, singleton, abstractions
Comments
Leave a Reply