taming coupling and cohesive beasts

106
TAMING COUPLING & COHESIVE BEASTS WITH MODULARITY PATTERNS By Param Rengaiah (@its_param)

Upload: param-rengaiah

Post on 16-May-2015

364 views

Category:

Technology


0 download

TRANSCRIPT

Page 1: Taming coupling and cohesive beasts

TAMING COUPLING & COHESIVE BEASTS WITH

MODULARITY PATTERNS By Param Rengaiah (@its_param)

Page 2: Taming coupling and cohesive beasts
Page 3: Taming coupling and cohesive beasts
Page 4: Taming coupling and cohesive beasts

Creating enterprise software system is incredibly

HARD

Page 5: Taming coupling and cohesive beasts

Keeping it useful and relevant is

10x HARDER

Page 6: Taming coupling and cohesive beasts

Cost percentage for maintenance is

70%

Page 7: Taming coupling and cohesive beasts

CHANGE

Accept and anticipate

Page 8: Taming coupling and cohesive beasts

ESSENTIAL

Change is not only desirable but

Page 9: Taming coupling and cohesive beasts

Spring framework growth from 14k loc in 2004 to 2013 is

1.3 MILLION

Page 10: Taming coupling and cohesive beasts

WHY?

Changing and enhancing an application is challenging.

Page 11: Taming coupling and cohesive beasts

VISION ARCHITECTS

Page 12: Taming coupling and cohesive beasts
Page 13: Taming coupling and cohesive beasts

REALITY IS After a year or so,

Page 14: Taming coupling and cohesive beasts
Page 15: Taming coupling and cohesive beasts
Page 16: Taming coupling and cohesive beasts
Page 17: Taming coupling and cohesive beasts
Page 18: Taming coupling and cohesive beasts

SPAGHETTI

Complicated, difficult to understand, and impossible to maintain is

Page 19: Taming coupling and cohesive beasts

BRIAN FOOTE JOSEPH YODER

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

Page 20: Taming coupling and cohesive beasts

DESIGN ROT

Tightly coupled code with excessive dependencies is known as

Page 21: Taming coupling and cohesive beasts

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 and cohesive beasts

TECHNICAL DEBT

When you choose to defer internal things that will impede future development, you incur

Page 23: Taming coupling and cohesive beasts

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 and cohesive beasts

If we know all these things, why does it still happen?

WHY?

Page 25: Taming coupling and cohesive beasts

MASK OFF

Lets take the

Page 26: Taming coupling and cohesive beasts

1 LOGICAL DESIGN FLAWS

Page 27: Taming coupling and cohesive beasts

PHIL KARLTON

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

Page 28: Taming coupling and cohesive beasts
Page 29: Taming coupling and cohesive beasts
Page 30: Taming coupling and cohesive beasts
Page 31: Taming coupling and cohesive beasts
Page 32: Taming coupling and cohesive beasts

2PHYSICAL & STRUCTURAL DESIGN FLAWS

Page 33: Taming coupling and cohesive beasts

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 and cohesive beasts

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 and cohesive beasts

THE BEAST LIVES!

THIS IS WHERE

Page 36: Taming coupling and cohesive beasts

VISION ARCHITECTS

Page 37: Taming coupling and cohesive beasts
Page 38: Taming coupling and cohesive beasts

REALITY IS?

Page 39: Taming coupling and cohesive beasts
Page 40: Taming coupling and cohesive beasts

HOW DO WE KNOW IF WE HAVE TAMED THE BEAST?

Page 41: Taming coupling and cohesive beasts

1 CONFIDENCE WHILE EMBRACING CHANGE

Page 42: Taming coupling and cohesive beasts

2PIVOT DESIGN WITH LEAST CASCADING DISRUPTION

Page 43: Taming coupling and cohesive beasts

3UNDERSTAND THE BUSINESS THROUGH CODE

Page 44: Taming coupling and cohesive beasts

MAINTAINING STATUS QUO IS NOT AN OPTION

Page 45: Taming coupling and cohesive beasts

LEHMAN’S LAW

Introducing

Page 46: Taming coupling and cohesive beasts

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

MANNY LEHMAN - LEHMAN’S SECOND LAW

Page 47: Taming coupling and cohesive beasts

REFACTOR? Should we

Page 48: Taming coupling and cohesive beasts

MARTIN FOWLER

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

Page 49: Taming coupling and cohesive beasts

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 50: Taming coupling and cohesive beasts
Page 51: Taming coupling and cohesive beasts
Page 52: Taming coupling and cohesive beasts
Page 53: Taming coupling and cohesive beasts

REDESIGN? Should we

Page 54: Taming coupling and cohesive beasts

S.O.L.I.D? Apply oop design principles like

Page 55: Taming coupling and cohesive beasts
Page 56: Taming coupling and cohesive beasts

DESIGN ROT

Tightly coupled code with excessive dependencies is known as

Page 57: Taming coupling and cohesive beasts

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 58: Taming coupling and cohesive beasts

RESTRUCTURING TO MODULARITY

Consider

Page 59: Taming coupling and cohesive beasts

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 60: Taming coupling and cohesive beasts

MODULE? What is a

Page 61: Taming coupling and cohesive beasts

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 62: Taming coupling and cohesive beasts

MANAGE RELATIONSHIPS

Page 63: Taming coupling and cohesive beasts

MODULE REUSE

Page 64: Taming coupling and cohesive beasts

COHESIVE MODULES

Page 65: Taming coupling and cohesive beasts

ACYCLIC RELATIONSHIPS

Page 66: Taming coupling and cohesive beasts

LEVELIZE MODULES

Page 67: Taming coupling and cohesive beasts

PHYSICAL LAYERS

Page 68: Taming coupling and cohesive beasts

CONTAINER INDEPENDENCE

Page 69: Taming coupling and cohesive beasts

INDEPENDENT DEPLOYMENT

Page 70: Taming coupling and cohesive beasts

PUBLISHED INTERFACE

Page 71: Taming coupling and cohesive beasts

EXTERNAL CONFIGURATION

Page 72: Taming coupling and cohesive beasts

DEFAULT IMPLEMENTATION

Page 73: Taming coupling and cohesive beasts

MODULE FAÇADE

Page 74: Taming coupling and cohesive beasts

ABSTRACT MODULES

Page 75: Taming coupling and cohesive beasts

IMPLEMENTATION FACTORY

Page 76: Taming coupling and cohesive beasts

SEPARATE ABSTRACTIONS

Page 77: Taming coupling and cohesive beasts

UTILITY PATTERNS

Page 78: Taming coupling and cohesive beasts

TOOLS You need the right

Page 79: Taming coupling and cohesive beasts

TOOLS

Spring Tool Suite

App ServerHibernate, Spring,

Spring Boots, Groovy

Page 80: Taming coupling and cohesive beasts
Page 81: Taming coupling and cohesive beasts
Page 82: Taming coupling and cohesive beasts
Page 83: Taming coupling and cohesive beasts
Page 84: Taming coupling and cohesive beasts
Page 85: Taming coupling and cohesive beasts
Page 86: Taming coupling and cohesive beasts
Page 87: Taming coupling and cohesive beasts
Page 88: Taming coupling and cohesive beasts

YAY!

Its time for a short demo.

Page 89: Taming coupling and cohesive beasts

OSGi?

What about

Page 90: Taming coupling and cohesive beasts
Page 91: Taming coupling and cohesive beasts

WHAT CAN WE INFER?

WITH WHAT WE HAVE SEEN SO FAR,

Page 92: Taming coupling and cohesive beasts

1. EXPOSE SEAMS OF THE SYSTEM

Page 93: Taming coupling and cohesive beasts

Seams?

Page 94: Taming coupling and cohesive beasts

2. ARCHITECT ALL THE WAY DOWN

Page 95: Taming coupling and cohesive beasts
Page 96: Taming coupling and cohesive beasts

WHAT CAN I DO NOW?

I WANT TO PREVENT OR FIX MY PROJECT

Page 97: Taming coupling and cohesive beasts

1 RECORD Design debts, hacks and quick wins

Page 98: Taming coupling and cohesive beasts

2 REVIEW The inventory at least every six months

Page 99: Taming coupling and cohesive beasts

3 REFACTOR Logical flaws as part of regular release cycles

Page 100: Taming coupling and cohesive beasts

4 PILOT The restructure for an isolated feature

Page 101: Taming coupling and cohesive beasts

5 PLAN A separate release for restructuring

Page 102: Taming coupling and cohesive beasts

6 CAMPAIGN And get the buy-in from stakeholders

Page 103: Taming coupling and cohesive beasts

7 RESTRUCTURE The system to modularity

Page 104: Taming coupling and cohesive beasts

If nothing is working, there’s always …

Page 105: Taming coupling and cohesive beasts

THANK YOU @its_param

Page 106: Taming coupling and cohesive beasts

http://www.adam-bien.com/roller/abien/entry/how_to_kill_an_osgi#comments 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