KEMBAR78
Applying software design principles in practice | PDF
How to apply design 
principles in practice? 
Ganesh Samarthyam! 
Consultant, ZineMind LLC! 
ganesh.samarthyam@zinemind.com
“Applying design principles is the key to creating 
high-quality software!” 
Architectural principles: ! 
Axis, symmetry, rhythm, datum, hierarchy, transformation
Technology changes fast => FOMO
Often frustrating to develop quality software!
There must be a better way! 
“Here is Edward Bear, 
coming downstairs now, 
bump, bump, bump, 
on the back of his head, 
behind Christopher Robin. 
It is, as far as ... 
! 
It is, as far as he knows, 
the only way of coming downstairs, 
but sometimes he feels that there 
really is another way, 
if only he could stop bumping for a 
moment and think of it!” 
! 
- A.A. Milne
Think, think, think!
Focus on software design is the key!
Real scenario #1 
Initial design
Real scenario #1 
❖ How will you refactor such 
that:! 
❖ A specific DES, AES, TDES, 
… can be “plugged” at 
runtime?! 
❖ Reuse these algorithms in 
new contexts? ! 
❖ Easily add support for new 
algorithms in Encryption? ! 
Next change: 
smelly design
Time to refactor! 
Three strikes and you 
refactor 
Martin Fowler
Potential solution #1? 
Broken 
hierarchy! 
Yuck! ! 
Your solution smells
Potential solution #2? 
Algorithms not 
reusable! 
Hmm, can be better. ! 
Better luck next time…
Potential solution #3? 
Wow!! 
What a nice solution :)
Can you identify the pattern?
You’re right: Its Strategy pattern!
Real scenario #2 
Initial design
Real scenario #2 
How to add support for new 
content types and/or algorithms? 
Yuck! ! 
This design smells
How about this solution? 
Wow!! 
What a nice solution :)
Can you identify the pattern structure?
You’re right: Its Bridge pattern!
Wait, what principle did we apply?
Open Closed Principle (OCP) 
Software entities should be open for 
extension, but closed for modification 
Bertrand Meyer
Variation Encapsulation Principle (VEP) 
Encapsulate the concept that varies 
Erich Gamma, Richard Helm, Ralph Johnson and John Vlissides
Fundamental principle: Encapsulation 
The principle of encapsulation advocates separation of concerns and! 
information hiding through techniques such as hiding implementation! 
details of abstractions and hiding variations
Enabling techniques for encapsulation
Other fundamental principles? 
Principles* 
Abstrac/on* 
Encapsula/on* 
Modulariza/on* 
Hierarchy*
Applying principles in practice 
Encapsulation 
Violating! 
encapsulation 
Adherence to ! 
encapsulation 
Applying ! 
encapsulation
Applying principles in practice 
Principle 
Violating! 
principles 
Adherence to ! 
principles 
Refactoring 
Bad design ! 
(with smells) 
Good design 
(with patterns)
Design determines qualities 
DESIGN 
impacts 
impacts 
impacts 
Understandability Changeability Extensibility 
Reusability Testability Reliability
“Applying design principles is the key to creating 
high-quality software!” 
Architectural principles: ! 
Axis, symmetry, rhythm, datum, hierarchy, transformation
Presentation source 
Forewords by 
Grady Booch and Dr. 
Stephane Ducasse
What are your takeaways?
Image/video credits 
❖ http://en.wikipedia.org/wiki/Fear_of_missing_out! 
❖ http://lesliejanemoran.blogspot.in/2010_05_01_archive.html! 
❖ http://javra.eu/wp-content/uploads/2013/07/angry_laptop2.jpg! 
❖ https://www.youtube.com/watch?v=5R8XHrfJkeg! 
❖ http://womenworld.org/image/052013/31/113745161.jpg! 
❖ http://www.fantom-xp.com/wallpapers/33/I'm_not_sure.jpg! 
❖ https://www.flickr.com/photos/31457017@N00/453784086 ! 
❖ https://www.gradtouch.com/uploads/images/question3.jpg! 
❖ http://gurujohn.files.wordpress.com/2008/06/bookcover0001.jpg ! 
❖ http://upload.wikimedia.org/wikipedia/commons/d/d5/Martin_Fowler_-_Swipe_Conference_2012.jpg! 
❖ http://www.codeproject.com/KB/architecture/csdespat_2/dpcs_br.gif ! 
❖ http://upload.wikimedia.org/wikipedia/commons/thumb/2/28/Bertrand_Meyer_IMG_2481.jpg/440px- 
Bertrand_Meyer_IMG_2481.jpg ! 
❖ http://takeji-soft.up.n.seesaa.net/takeji-soft/image/GOF-OOPLSA-94-Color-75.jpg?d=a0 ! 
❖ https://developer.apple.com/library/ios/documentation/cocoa/Conceptual/OOP_ObjC/Art/watchcalls_35.gif! 
❖ http://www.pluspack.com/files/billeder/Newsletter/25/takeaway_bag.png ! 
❖ http://cdn1.tnwcdn.com/wp-content/blogs.dir/1/files/2013/03/design.jpg
Applying software design principles in practice

Applying software design principles in practice

  • 1.
    How to applydesign principles in practice? Ganesh Samarthyam! Consultant, ZineMind LLC! ganesh.samarthyam@zinemind.com
  • 2.
    “Applying design principlesis the key to creating high-quality software!” Architectural principles: ! Axis, symmetry, rhythm, datum, hierarchy, transformation
  • 3.
  • 4.
    Often frustrating todevelop quality software!
  • 5.
    There must bea better way! “Here is Edward Bear, coming downstairs now, bump, bump, bump, on the back of his head, behind Christopher Robin. It is, as far as ... ! It is, as far as he knows, the only way of coming downstairs, but sometimes he feels that there really is another way, if only he could stop bumping for a moment and think of it!” ! - A.A. Milne
  • 6.
  • 7.
    Focus on softwaredesign is the key!
  • 8.
    Real scenario #1 Initial design
  • 9.
    Real scenario #1 ❖ How will you refactor such that:! ❖ A specific DES, AES, TDES, … can be “plugged” at runtime?! ❖ Reuse these algorithms in new contexts? ! ❖ Easily add support for new algorithms in Encryption? ! Next change: smelly design
  • 10.
    Time to refactor! Three strikes and you refactor Martin Fowler
  • 11.
    Potential solution #1? Broken hierarchy! Yuck! ! Your solution smells
  • 12.
    Potential solution #2? Algorithms not reusable! Hmm, can be better. ! Better luck next time…
  • 13.
    Potential solution #3? Wow!! What a nice solution :)
  • 14.
    Can you identifythe pattern?
  • 15.
    You’re right: ItsStrategy pattern!
  • 16.
    Real scenario #2 Initial design
  • 17.
    Real scenario #2 How to add support for new content types and/or algorithms? Yuck! ! This design smells
  • 18.
    How about thissolution? Wow!! What a nice solution :)
  • 19.
    Can you identifythe pattern structure?
  • 20.
    You’re right: ItsBridge pattern!
  • 21.
    Wait, what principledid we apply?
  • 22.
    Open Closed Principle(OCP) Software entities should be open for extension, but closed for modification Bertrand Meyer
  • 23.
    Variation Encapsulation Principle(VEP) Encapsulate the concept that varies Erich Gamma, Richard Helm, Ralph Johnson and John Vlissides
  • 24.
    Fundamental principle: Encapsulation The principle of encapsulation advocates separation of concerns and! information hiding through techniques such as hiding implementation! details of abstractions and hiding variations
  • 25.
  • 26.
    Other fundamental principles? Principles* Abstrac/on* Encapsula/on* Modulariza/on* Hierarchy*
  • 27.
    Applying principles inpractice Encapsulation Violating! encapsulation Adherence to ! encapsulation Applying ! encapsulation
  • 28.
    Applying principles inpractice Principle Violating! principles Adherence to ! principles Refactoring Bad design ! (with smells) Good design (with patterns)
  • 29.
    Design determines qualities DESIGN impacts impacts impacts Understandability Changeability Extensibility Reusability Testability Reliability
  • 30.
    “Applying design principlesis the key to creating high-quality software!” Architectural principles: ! Axis, symmetry, rhythm, datum, hierarchy, transformation
  • 31.
    Presentation source Forewordsby Grady Booch and Dr. Stephane Ducasse
  • 32.
    What are yourtakeaways?
  • 33.
    Image/video credits ❖http://en.wikipedia.org/wiki/Fear_of_missing_out! ❖ http://lesliejanemoran.blogspot.in/2010_05_01_archive.html! ❖ http://javra.eu/wp-content/uploads/2013/07/angry_laptop2.jpg! ❖ https://www.youtube.com/watch?v=5R8XHrfJkeg! ❖ http://womenworld.org/image/052013/31/113745161.jpg! ❖ http://www.fantom-xp.com/wallpapers/33/I'm_not_sure.jpg! ❖ https://www.flickr.com/photos/31457017@N00/453784086 ! ❖ https://www.gradtouch.com/uploads/images/question3.jpg! ❖ http://gurujohn.files.wordpress.com/2008/06/bookcover0001.jpg ! ❖ http://upload.wikimedia.org/wikipedia/commons/d/d5/Martin_Fowler_-_Swipe_Conference_2012.jpg! ❖ http://www.codeproject.com/KB/architecture/csdespat_2/dpcs_br.gif ! ❖ http://upload.wikimedia.org/wikipedia/commons/thumb/2/28/Bertrand_Meyer_IMG_2481.jpg/440px- Bertrand_Meyer_IMG_2481.jpg ! ❖ http://takeji-soft.up.n.seesaa.net/takeji-soft/image/GOF-OOPLSA-94-Color-75.jpg?d=a0 ! ❖ https://developer.apple.com/library/ios/documentation/cocoa/Conceptual/OOP_ObjC/Art/watchcalls_35.gif! ❖ http://www.pluspack.com/files/billeder/Newsletter/25/takeaway_bag.png ! ❖ http://cdn1.tnwcdn.com/wp-content/blogs.dir/1/files/2013/03/design.jpg