taming coupling & cohesive beasts with modularity patterns and spring

98
© 2013 SpringOne 2GX. All rights reserved. Do not distribute without permission. TAMING COUPLING & COHESIVE BEASTS WITH MODULARITY PATTERNS AND SPRING By Param Rengaiah

Post on 17-Sep-2014

16 views

Category:

Technology


1 download

DESCRIPTION

Speaker: Param Rengaiah By now you should have heard about coupling and cohesiveness. These concepts, and their third cousin, polymorphism, is what we as developers chase day-in and day-out. They tease us with reusability and the promise of comprehensiveness of our code. They entice us with promises of code quality and testability. They came in the form of "Object Oriented' design, followed by GoF and SOLID Design Patterns, DDD, BDD.. but none of them delivered what they promised. Now, the new kids on the block are Functional Programming and Modularity Patterns. What happens when you choose to go through large refactoring exercise on the back of Modularity Patterns, in a large, complex enterprise project? The journey was long, arduous and gruesome. On the way, I made many enemies and found some new friends. This talk will highlight the issues, both technical and otherwise, and how it was overcome; where did Spring help and where did it hurt. In the end, was it worth it? Come to this session and you will find out.

TRANSCRIPT

Page 1: Taming Coupling & Cohesive Beasts with Modularity Patterns and Spring

© 2013 SpringOne 2GX. All rights reserved. Do not distribute without permission.

TAMING COUPLING & COHESIVE BEASTS WITH MODULARITY PATTERNS AND SPRING

By Param Rengaiah

Page 2: Taming Coupling & Cohesive Beasts with Modularity Patterns and Spring
Page 3: Taming Coupling & Cohesive Beasts with Modularity Patterns and Spring
Page 4: Taming Coupling & Cohesive Beasts with Modularity Patterns and Spring

CREATING ENTERPRISE SOFTWARE SYSTEM IS INCREDIBLY

HARD

Page 5: Taming Coupling & Cohesive Beasts with Modularity Patterns and Spring

KEEPING IT USEFUL AND RELEVANT IS

HERCULEAN

Page 6: Taming Coupling & Cohesive Beasts with Modularity Patterns and Spring

COST PERCENTAGE FOR MAINTENANCE IS

70%

Page 7: Taming Coupling & Cohesive Beasts with Modularity Patterns and Spring

CHANGE

ACCEPT AND ANTICIPATE

Page 8: Taming Coupling & Cohesive Beasts with Modularity Patterns and Spring

ESSENTIAL

CHANGE IS NOT ONLY DESIRABLE BUT

Page 9: Taming Coupling & Cohesive Beasts with Modularity Patterns and Spring

SPRING FRAMEWORK GROWTH FROM 14K LOC IN 2004 TO 2013 IS

1.3 MILLION

Page 10: Taming Coupling & Cohesive Beasts with Modularity Patterns and Spring

WHY?

CHANGING AND ENHANCING AN APPLICATION IS CHALLENGING.

Page 11: Taming Coupling & Cohesive Beasts with Modularity Patterns and Spring

VISION ARCHITECTS

Page 12: Taming Coupling & Cohesive Beasts with Modularity Patterns and Spring
Page 13: Taming Coupling & Cohesive Beasts with Modularity Patterns and Spring

REALITY IS AFTER A YEAR OR SO,

Page 14: Taming Coupling & Cohesive Beasts with Modularity Patterns and Spring
Page 15: Taming Coupling & Cohesive Beasts with Modularity Patterns and Spring
Page 16: Taming Coupling & Cohesive Beasts with Modularity Patterns and Spring
Page 17: Taming Coupling & Cohesive Beasts with Modularity Patterns and Spring
Page 18: Taming Coupling & Cohesive Beasts with Modularity Patterns and Spring

SPAGHETTI

COMPLICATED, DIFFICULT TO UNDERSTAND, AND IMPOSSIBLE TO MAINTAIN IS

Page 19: Taming Coupling & Cohesive Beasts with Modularity Patterns and Spring

BRIAN FOOTE JOSEPH YODER

[ Big ball of mud / spaghetti ] systems show unmistakable signs of unregulated growth and repeated, expedient repair.

Page 20: Taming Coupling & Cohesive Beasts with Modularity Patterns and Spring

DESIGN ROT

TIGHTLY COUPLED CODE WITH EXCESSIVE DEPENDENCIES IS KNOWN AS

Page 21: Taming Coupling & Cohesive Beasts with Modularity Patterns and Spring

ROBERT C. MARTIN (UNCLE BOB)

There are four primary symptoms that tell us that our designs are rotting : rigidity, fragility, immobility, and viscosity.

Page 22: Taming Coupling & Cohesive Beasts with Modularity Patterns and Spring

TECHNICAL DEBT

WHEN YOU CHOOSE TO DEFER INTERNAL THINGS THAT WILL IMPEDE FUTURE DEVELOPMENT, YOU INCUR

Page 23: Taming Coupling & Cohesive Beasts with Modularity Patterns and Spring

MARTIN FOWLER

Development organizations let their debt get out of control and spend most of their future development effort paying crippling interest payments.

Page 24: Taming Coupling & Cohesive Beasts with Modularity Patterns and Spring

IF WE KNOW ALL THESE THINGS, WHY DOES IT STILL HAPPEN?

WHY?

Page 25: Taming Coupling & Cohesive Beasts with Modularity Patterns and Spring

MASK OFF

LETS TAKE THE

Page 26: Taming Coupling & Cohesive Beasts with Modularity Patterns and Spring

1 LOGICAL DESIGN FLAWS

Page 27: Taming Coupling & Cohesive Beasts with Modularity Patterns and Spring

PHIL KARLTON

There are only two hard things in Computer Science: cache invalidation and naming things.

Page 28: Taming Coupling & Cohesive Beasts with Modularity Patterns and Spring
Page 29: Taming Coupling & Cohesive Beasts with Modularity Patterns and Spring
Page 30: Taming Coupling & Cohesive Beasts with Modularity Patterns and Spring
Page 31: Taming Coupling & Cohesive Beasts with Modularity Patterns and Spring
Page 32: Taming Coupling & Cohesive Beasts with Modularity Patterns and Spring

2PHYSICAL & STRUCTURAL DESIGN FLAWS

Page 33: Taming Coupling & Cohesive Beasts with Modularity Patterns and Spring

The physical architecture is the skeleton of the system – if it is malformed, there is no cosmetic remedy for alleviating its unpleasant symptoms.

JOHN LAKOS

Page 34: Taming Coupling & Cohesive Beasts with Modularity Patterns and Spring

JOHN LAKOS

The quality of the physical design of a large system will dictate the cost of its maintenance and the potential it has for the independent reuse of its subsystems.

Page 35: Taming Coupling & Cohesive Beasts with Modularity Patterns and Spring

THE BEAST LIVES!

THIS IS WHERE

Page 36: Taming Coupling & Cohesive Beasts with Modularity Patterns and Spring
Page 37: Taming Coupling & Cohesive Beasts with Modularity Patterns and Spring

REALITY IS?

Page 38: Taming Coupling & Cohesive Beasts with Modularity Patterns and Spring
Page 39: Taming Coupling & Cohesive Beasts with Modularity Patterns and Spring

HOW DO WE KNOW WE HAVE TAMED THE BEAST?

Page 40: Taming Coupling & Cohesive Beasts with Modularity Patterns and Spring

1 CONFIDENCE WHILE EMBRACING CHANGE

Page 41: Taming Coupling & Cohesive Beasts with Modularity Patterns and Spring

2PIVOT DESIGN WITH LEAST CASCADING DISRUPTION

Page 42: Taming Coupling & Cohesive Beasts with Modularity Patterns and Spring

3UNDERSTAND THE BUSINESS THROUGH CODE

Page 43: Taming Coupling & Cohesive Beasts with Modularity Patterns and Spring
Page 44: Taming Coupling & Cohesive Beasts with Modularity Patterns and Spring
Page 45: Taming Coupling & Cohesive Beasts with Modularity Patterns and Spring
Page 46: Taming Coupling & Cohesive Beasts with Modularity Patterns and Spring

LEHMAN’S LAW

INTRODUCING

Page 47: Taming Coupling & Cohesive Beasts with Modularity Patterns and Spring

As a system evolves, its complexity increases unless work is done to maintain or reduce it.

MANNY LEHMAN - LEHMAN’S SECOND LAW

Page 48: Taming Coupling & Cohesive Beasts with Modularity Patterns and Spring

REFACTOR? SHOULD WE

Page 49: Taming Coupling & Cohesive Beasts with Modularity Patterns and Spring

MARTIN FOWLER

Refactoring is a disciplined technique for restructuring an existing body of code, altering its internal structure without changing its external behavior.

Page 50: Taming Coupling & Cohesive Beasts with Modularity Patterns and Spring

MARTIN FOWLER

Its heart is a series of small behavior preserving transformations. Each transformation does little, but a sequence such transformations can produce a significant restructuring.

Page 51: Taming Coupling & Cohesive Beasts with Modularity Patterns and Spring

S.O.L.I.D? APPLY OOP DESIGN PRINCIPLES LIKE

Page 52: Taming Coupling & Cohesive Beasts with Modularity Patterns and Spring
Page 53: Taming Coupling & Cohesive Beasts with Modularity Patterns and Spring

DESIGN ROT

TIGHTLY COUPLED CODE WITH EXCESSIVE DEPENDENCIES IS KNOWN AS

Page 54: Taming Coupling & Cohesive Beasts with Modularity Patterns and Spring

The physical architecture is the skeleton of the system – if it is malformed, there is no cosmetic remedy for alleviating its unpleasant symptoms.

JOHN LAKOS

Page 55: Taming Coupling & Cohesive Beasts with Modularity Patterns and Spring

RESTRUCTURING TO MODULARITY

Page 56: Taming Coupling & Cohesive Beasts with Modularity Patterns and Spring

MARTIN FOWLER

I see refactoring as a very specific technique to do the more general activity of restructuring. Restructuring is any rearrangement of parts of a whole.

Page 57: Taming Coupling & Cohesive Beasts with Modularity Patterns and Spring

I’m dancing! By God I’m dancing on the walls. I’m dancing on the ceiling. I’m ecstatic. I’m overjoyed. I’m really, really pleased.

FROM THE FOREWORD BY ROBERT C. MARTIN

Page 58: Taming Coupling & Cohesive Beasts with Modularity Patterns and Spring

MANAGE RELATIONSHIPS

Page 59: Taming Coupling & Cohesive Beasts with Modularity Patterns and Spring

MODULE REUSE

Page 60: Taming Coupling & Cohesive Beasts with Modularity Patterns and Spring

COHESIVE MODULES

Page 61: Taming Coupling & Cohesive Beasts with Modularity Patterns and Spring

ACYCLIC RELATIONSHIPS

Page 62: Taming Coupling & Cohesive Beasts with Modularity Patterns and Spring

LEVELIZE MODULES

Page 63: Taming Coupling & Cohesive Beasts with Modularity Patterns and Spring

PHYSICAL LAYERS

Page 64: Taming Coupling & Cohesive Beasts with Modularity Patterns and Spring

CONTAINER INDEPENDENCE

Page 65: Taming Coupling & Cohesive Beasts with Modularity Patterns and Spring

INDEPENDENT DEPLOYMENT

Page 66: Taming Coupling & Cohesive Beasts with Modularity Patterns and Spring

PUBLISHED INTERFACE

Page 67: Taming Coupling & Cohesive Beasts with Modularity Patterns and Spring

EXTERNAL CONFIGURATION

Page 68: Taming Coupling & Cohesive Beasts with Modularity Patterns and Spring

DEFAULT IMPLEMENTATION

Page 69: Taming Coupling & Cohesive Beasts with Modularity Patterns and Spring

MODULE FAÇADE

Page 70: Taming Coupling & Cohesive Beasts with Modularity Patterns and Spring

ABSTRACT MODULES

Page 71: Taming Coupling & Cohesive Beasts with Modularity Patterns and Spring

IMPLEMENTATION FACTORY

Page 72: Taming Coupling & Cohesive Beasts with Modularity Patterns and Spring

SEPARATE ABSTRACTIONS

Page 73: Taming Coupling & Cohesive Beasts with Modularity Patterns and Spring

UTILITY PATTERNS

Page 74: Taming Coupling & Cohesive Beasts with Modularity Patterns and Spring

TOOLS YOU NEED THE RIGHT

Page 75: Taming Coupling & Cohesive Beasts with Modularity Patterns and Spring

TOOLS

Spring Tool Suite

App Server Hibernate, Spring, Spring Boots, Groovy

Page 76: Taming Coupling & Cohesive Beasts with Modularity Patterns and Spring
Page 77: Taming Coupling & Cohesive Beasts with Modularity Patterns and Spring
Page 78: Taming Coupling & Cohesive Beasts with Modularity Patterns and Spring
Page 79: Taming Coupling & Cohesive Beasts with Modularity Patterns and Spring
Page 80: Taming Coupling & Cohesive Beasts with Modularity Patterns and Spring
Page 81: Taming Coupling & Cohesive Beasts with Modularity Patterns and Spring
Page 82: Taming Coupling & Cohesive Beasts with Modularity Patterns and Spring
Page 83: Taming Coupling & Cohesive Beasts with Modularity Patterns and Spring
Page 84: Taming Coupling & Cohesive Beasts with Modularity Patterns and Spring

YAY!

ITS TIME FOR A SHORT DEMO.

Page 85: Taming Coupling & Cohesive Beasts with Modularity Patterns and Spring

SO, WHAT CAN WE INFER?

Page 86: Taming Coupling & Cohesive Beasts with Modularity Patterns and Spring

1. EXPOSE SEAMS OF THE SYSTEM

Page 87: Taming Coupling & Cohesive Beasts with Modularity Patterns and Spring

2. ARCHITECT ALL THE WAY DOWN

Page 88: Taming Coupling & Cohesive Beasts with Modularity Patterns and Spring

WHAT NOW?

I CAN’T START THE RESTRUCTURE TODAY.

Page 89: Taming Coupling & Cohesive Beasts with Modularity Patterns and Spring

1 RECORD DESIGN DEBTS, HACKS AND QUICK WINS

Page 90: Taming Coupling & Cohesive Beasts with Modularity Patterns and Spring

2 REVIEW THE INVENTORY AT LEAST EVERY SIX MONTHS

Page 91: Taming Coupling & Cohesive Beasts with Modularity Patterns and Spring

3 REFACTOR LOGICAL FLAWS AS PART OF REGULAR RELEASE CYCLES

Page 92: Taming Coupling & Cohesive Beasts with Modularity Patterns and Spring

4 PILOT THE RESTRUCTURE FOR AN ISOLATED FUNCTION

Page 93: Taming Coupling & Cohesive Beasts with Modularity Patterns and Spring

5 PLAN A SEPARATE RELEASE FOR RESTRUCTURING

Page 94: Taming Coupling & Cohesive Beasts with Modularity Patterns and Spring

6 CAMPAIGN AND GET THE BUY-IN FROM STAKEHOLDERS

Page 95: Taming Coupling & Cohesive Beasts with Modularity Patterns and Spring

7 RESTRUCTURE THE SYSTEM TO MODULARITY

Page 96: Taming Coupling & Cohesive Beasts with Modularity Patterns and Spring

THANK YOU @its_param

Page 97: Taming Coupling & Cohesive Beasts with Modularity Patterns and Spring

http://baruzzo.wordpress.com/2009/07/01/physical-design-vs-logical-design-part-i/ http://blogs.msdn.com/b/ericlippert/archive/2009/04/06/good-names.aspx http://docs.oracle.com/javaee/6/tutorial/doc/bnadx.html http://en.wikipedia.org/wiki/Lehman's_laws_of_software_evolution http://en.wikipedia.org/wiki/Technical_debt http://interactiveasp.net/blogs/softwarepsychology/archive/2009/12/23/the-blame-game.aspx http://martinfowler.com/bliki/RefactoringMalapropism.html http://martinfowler.com/bliki/TechnicalDebt.html http://martinfowler.com/bliki/TechnicalDebt.html http://martinfowler.com/books/refactoring.html http://mikadomethod.wordpress.com/2009/12/09/introduction-to-the-mikado-method/#more-1 http://stackoverflow.com/questions/1030388/how-to-overcome-the-anti-pattern-big-ball-of-mud http://upload.wikimedia.org/wikipedia/commons/7/7b/Hammer2.jpg http://www.codinghorror.com/blog/2006/05/the-long-dismal-history-of-software-project-failure.html http://www.codinghorror.com/blog/2007/11/the-big-ball-of-mud-and-other-architectural-disasters.html http://www.construx.com/10x_Software_Development/Technical_Debt/ http://www.flickr.com/photos/tambako/494118044/ http://www.informit.com/authors/bio.aspx?a=410e6d20-a168-41cb-8d5e-93b14e4843d9 http://www.jsjf.demon.co.uk/thesis/Thesis.html http://www.kirkk.com/modularity/2009/12/chapter-5-taming-the-beast/ http://www.kirkk.com/modularity/pattern-catalog/ http://www.laputan.org/mud/ http://www.ohloh.net/p/spring/analyses/latest/languages_summary

REFERENCES AND ACKNOWLEDGEMENTS

Page 98: Taming Coupling & Cohesive Beasts with Modularity Patterns and Spring

https://medium.com/@its_param https://medium.com/on-software-architecture/46603626bc1e Twitter: twitter.com/springsource YouTube: youtube.com/user/SpringSourceDev Google +: plus.google.com/+springframework LinkedIn: springsource.org/linkedin Facebook: facebook.com/groups/springsource

Learn More. Stay Connected.