Professional Documents
Culture Documents
Welcome To Design Patterns
Welcome To Design Patterns
Rubber ducks
don’t quack,
so quack () is
overridden to
Squeak”
Inheritance….
Food for thought
• What are disadvantages of using inheritance?
How about an interface
Code duplication
CHANGE
• Change is the only constant in software
development
• Code always needs change
• Build software such that change has
– Least possible impact on existing code
– Need less time for reworking
Design Principle 1
• Identify the aspects of your
application that vary and separate
them from what stays the same.
• Take what varies and “encapsulate” it so it won’t
affect rest of your code
• Result? Fewer unintended consequences from code
changes and more flexibility in your systems
Separating what varies from what
stays the same
• Fly() and Quack() vary across all the ducks
Design Principle 2
• Program to an interface, not an
implementation.
And
Be Happy!!!