Design Patterns - in Dynamic Languages Presentation
Design Patterns - in Dynamic Languages Presentation
“design patterns”
in dynamic languages
NEAL FORD software architect / meme wrangler
ThoughtWorks
[email protected]
3003 Summit Boulevard, Atlanta, GA 30319
www.nealford.com
www.thoughtworks.com
memeagora.blogspot.com
ThoughtWorks
pattern solutions from weaker languages
vs.
essence
internal vs. external
iterators
.each in groovy & ruby are internal iterators
1.9
command
Encapsulate a request as an object, thereby letting you
parameterize clients with different requests, queue or log
requests, and support undoable operations.
commands == closures
Encapsulate a request as an object, thereby letting you
parameterize clients with different requests, queue or log
requests, and support undoable operations.
command design pattern is
built into languages
with closures
steve
yegge
builder
Separate the construction of a complex object from its
representation so that the same construction process
can create different representations.
“traditional” builder
add dynamic behavior: ad
hoc combinations
in computer_builder:
template
Define the skeleton of an algorithm in an operation,
deferring some steps to subclasses. Template Method
lets subclasses redefine certain steps of an algorithm
without changing the algorithm’s structure.
what’s dynamic?
why
grams & not
lbs?
of redux
who returns what?
BigDecimal Ingredient
Integer Ingredient
type transmogrification
transform types as needed as part of a
fluent interface call
embedded interpreter
what is this?
method “bubble” word
patterns
null object
The null object pattern uses a special object
representing null, instead of using an actual null. The
result of using the null object should semantically be
equivalent to doing nothing.
java.lang.NullPointerException
this pattern doesn't
exist in ruby
NilClass is already
defined
aridifier
dry
don’t
repeat
yourself
ceremonious languages
generate floods
essence
languages
allow
aridification
moist
tests?
drier tests
“traditional” design patterns rely
heavily on structure to solve problems
dynamic languages use
language facilities to create
simpler solutions
understand patterns
for what they are...
descriptions of
common problems
implement solutions that
take advantage of your tools
ThoughtWorks
questions?
please fill out the session evaluations
slides & samples available at nealford.com
ThoughtWorks
This work is licensed under the Creative Commons
[email protected]
Attribution-Noncommercial-Share Alike 2.5 License. 3003 Summit Boulevard, Atlanta, GA 30319
www.nealford.com
http://creativecommons.org/licenses/by-nc-sa/2.5/ www.thoughtworks.com
memeagora.blogspot.com
ThoughtWorks
resources