The Decorator
Application of a design pattern
Christopher Thomas�Sr. Web Developer - VirPack
Wait, what's a Design Pattern?
Quoth Wikipedia:
"A design pattern is a general reusable solution to a commonly occurring problem within a given context in software design"
So it's like a blueprint.
Ok, so what's a Decorator?
"The decorator pattern is a design pattern that allows behavior to be added to an individual object, either statically or dynamically, without affecting the behavior of other objects from the same class"
So it's one of those Russian Dolls?
Yes, and they're called Matryoshka. Bonus points if you know why Khrushchev is pictured with corn.
Validation is hard
(and it gets harder the more knobs and twiddly bits you incorporate)
Why validation is hard
Multiple...
Difficult to...
I was going to put some example of password validation code here but it ended up being 53 lines long and I couldn't fit it on the slide - which sort of illustrates the point.
Validation by Decoration
Open/Closed Principle
"Software entities should be open for extension but closed for modification."
Additional validation features can be added without altering existing ones.
Ok, but how does that work?
*The fine print
MOAR PATTERNS!
Singleton
Factory
State
Iterator
Property (get, set)
Adapter
Facade
Strategy�Etc
Questions?
Comments? Ideas? Thoughts?�Why not have another cookie?