Awesome
Design Pattern
Playing with Design Pattern
using Modern Perl
. This is not the first time anyone has done it and definitely not the last. It is an honest attempt to show the power of Modern Perl
. If you look at the individual implementation, you will appreciate it does not take much to get the job done.
To keep it lightweight, I am using Moo for the class definition.
- 1. Factory
- 2. Abstract Factory
- 3. Decorator
- 4. Facade
- 5. Singleton
- 6. Composite
- 7. Builder
- 8. State
- 9. Observer
- 10. Proxy
- 11. Template
- 12. Filter
- 13. Bridge
- 14. Iterator
- 15. Prototype
- 16. Data Access Object (DAO)
- 17. Adapter
With the release of Perl v5.38
which brings in new experimental feature 'class'
to the core, I am trying to re-create the above implementation (with Moo
family) using the new experimental feature 'class'
. It wouldn't be possible to get everything done yet as we don't have the keyword 'role'
in the core as in v5.38
.
Commonly used Keywords:
Interface:
An interface generally defines the set of methods that an instance of a class that has that interface could respond to.
It defines a set of methods, the class that implements it "repeats" the same methods, but provides definition, so interface looks like skeleton of the class.
Abstract Class:
An abstract class is a class that contains at least one abstract method. An abstract method is a method that is declared, but not implemented in the code.
Concrete Class:
A concrete class is a class that has an implementation for all of its methods. They cannot have any unimplemented methods. It can also extend an abstract class or implement an interface as long as it implements all their methods.
AUTHOR
Mohammad S Anwar, <mohammad.anwar at yahoo.com>
CONTRIBUTORS
- E. Choroba
- Julien Fiegehenn