Attain Clean Code in Sitecore Solutions using Design Patterns
-
Upload
michael-reynolds -
Category
Software
-
view
244 -
download
3
Transcript of Attain Clean Code in Sitecore Solutions using Design Patterns
Sitecore User Group Conference 2015 1
Attain Clean Code in Sitecore Solutions using Design Patterns
Mike Reynolds
Hanson Dodge Creative
@mike_i_reynolds
Sitecore User Group Conference 2015 2
What’s a Design Pattern?
• “General reusable solution to a commonly occurring
problem“• http://en.wikipedia.org/wiki/Software_design_pattern
• Describes how to solve a problem
• Can be across different contexts
• Provides a common language for developers
• Is not a cookie-cutter code solution!
Sitecore User Group Conference 2015 3
Design Patterns: History
• Proposed by Christopher Alexander (1970s)
• A Pattern Language: Towns, Buildings, Construction (
http://amzn.to/1BtaaIH)
• Kent Beck and Ward Cunningham applied the concept
to programming (1987)
• Presented results at Object-Oriented Programming, Systems,
Languages & Applications (OOPSLA)
Sitecore User Group Conference 2015 4
Design Patterns: History
• Gang of Four (GoF) Book (1994)
• Design Patterns: Elements of Reusable Object-Oriented
Software. (http://amzn.to/UPNN2F)
• Erich Gamma, Richard Helm, Ralph Johnson, and John
Vlissides
Sitecore User Group Conference 2015 5
Design Patterns: Examples
• Adapter
• Decorator
• Composite
• Chain-of-responsibility
• Null Object
Sitecore User Group Conference 2015 6
Adapter Pattern
• Allows the interface of an existing class to be used from
another
• A “wrapper”
• Makes existing classes work with others without modifying
their source code
Sitecore User Group Conference 2015 8
Decorator Pattern
• Encapsulates an object with the same interface
• Also a “wrapper”
• Adds/removes/alters functionality on the inner instance
Sitecore User Group Conference 2015 10
Composite Pattern
• Encapsulates a collection of objects with the same
interface
• Treats the entire collection as one object
Sitecore User Group Conference 2015 12
Chain-of-responsibility Pattern
• Composed of command objects and a series of
processing objects
• Each processing object executes specific command
objects
• Processing objects are chained together
• think linked list
• Processing objects are invoked in a cascading manner
Sitecore User Group Conference 2015 13
Null Object Pattern
• Represents the “null” state of an object
• Provides methods with no behaviour
• Removes the need of client code performing null
checks
Sitecore User Group Conference 2015 14
Learn More!
• Recommend Books
• http://amzn.to/UPNN2F
• http://amzn.to/1ppJHeH
• http://amzn.to/1EZEa3z
• http://amzn.to/1bSAYsh
• Blog posts
• http://bit.ly/1E7J7JO
Sitecore User Group Conference 2015 15
Get In Touch!
Blog: http://sitecorejunkie.com
Twitter: @mike_i_reynolds
LinkedIn: http://linkd.in/1Csu1N8