2. SESSION RESOURCES
• Presentation session notes including link to this session, will be
available on http://learningaboutfudge.blogspot.com
• All the source for this session is publically available at:
https://github.com/SheepWorx/Training
• RSS Feed:
http://learningaboutfudge.blogspot.com/feeds/posts/default?alt=rs
s
• Local Network: dmeyer-msharetrainingCode Like a Ninja
• Source was compiled using Visual Studio 2012
• http://www.gofpatterns.com/
4. STRUCTURAL DESIGN PATTERNS
Definition
Structural design patterns are design patterns that ease the
design by identifying a simple way to realize relationships
between entities. Structural patterns are for tying together
existing function.
6. ADAPTER PATTERN
• Acts as an intermediary between two classes
• Enables incompatible interfaces to work together
• Implements an interface known to its clients and provides
access to an instance of class not known to its clients
8. ADAPTER PATTERN – BENEFITS
• Allows two or more incompatible objects to communicate and
interact
• Improves reusability of older functionality
9. ADAPTER PATTERN – WHEN TO USE IT
• You want to use an existing class, and its interface does not match
the interface you need.
• You want to create a reusable class that cooperates with unrelated or
unforeseen classes, that is, classes that do not necessarily have
compatible interfaces.
• You want to use an object in an environment that expects an
interface that is different from the object's interface.
• Interface translation among multiple sources must occur.
11. COMPOSITE PATTERN
• Enables you to create hierarchical tree of varying complexity
Motivation
When dealing with Tree-structured data, programmers often
have to discriminate between a leaf-node and a branch. The
solution is an interface that allows treating complex and
primitive objects uniformly.
13. COMPOSITE PATTERN – BENEFITS
• Defines class hierarchies consisting of primitive objects and
composite objects
• Makes it easier to add new kinds of components
• Provides flexibility of structure and a manageable interface
14. COMPOSITE PATTERN – WHEN TO USE IT
• You want to represent the whole hierarchy or part of the
hierarchy of objects.
• You want clients to be able to ignore the difference between
compositions of objects and individual objects.
• The structure can have any level of complexity, and is dynamic.
18. DECORATOR PATTERN – BENEFITS
• More flexibility than static inheritance.
• Avoids feature-laden classes high up in the hierarchy
• Simplifies coding because you write a series of classes, each
targeted at a specific part of the functionality, rather than
coding all behaviour into the object
• Enhances the object's extensibility because you make changes
by coding new classes.
19. DECORATOR PATTERN – WHEN TO USE IT
• You want to add responsibilities to individual objects
dynamically and transparently, that is without affecting other
objects
• You want to add responsibilities to the object that you want to
change in the future
• When extension by static sub-classing is impractical.
21. SESSION RESOURCES
• Presentation session notes including link to this session, will be
available on http://learningaboutfudge.blogspot.com
• All the source for this session is publically available at:
https://github.com/SheepWorx/Training
• RSS Feed:
http://learningaboutfudge.blogspot.com/feeds/posts/default?alt=rs
s
• Local Network: dmeyer-msharetrainingCode Like a Ninja
• Source was compiled using Visual Studio 2012
• http://www.gofpatterns.com/