taming coupling and cohesive beasts

65
© 2013 Spring, by Pivotal TAMING COUPLING & COHESIVE BEASTS WITH MODULARITY PATTERNS AND SPRING Param Rengaiah, Experience Architect @its_param

Upload: param-rengaiah

Post on 26-Jan-2015

116 views

Category:

Technology


3 download

DESCRIPTION

 

TRANSCRIPT

Page 1: Taming coupling and cohesive beasts

© 2013 Spring, by Pivotal

TAMING COUPLING & COHESIVE BEASTSWITH MODULARITY PATTERNS AND SPRING

Param Rengaiah, Experience Architect@its_param

Page 2: Taming coupling and cohesive beasts

22

Creating enterprise software system is incredibly HARD.

Page 3: Taming coupling and cohesive beasts

33

Keeping it useful and relevantis even more

HARDER!

http://www.flickr.com/photos/teddyllovet/9421262432/

Page 4: Taming coupling and cohesive beasts

44

70%That’s the percentage cost spent on maintaining large enterprise

applications.

Page 5: Taming coupling and cohesive beasts

55

CHANGEis not only essential but desirable

Page 6: Taming coupling and cohesive beasts

66

SPRING FRAMEWORK

LOC on March 2004 – 14 K LOC on August 2013 – 1.3 M

Page 7: Taming coupling and cohesive beasts

77

WHY?is it difficult to modify and enhance an application?

Page 8: Taming coupling and cohesive beasts

88

BACKSTORYMy personal journey and why I am passionate about this subject.

Page 9: Taming coupling and cohesive beasts

99

Possible Reasons

Development spends too much time in understanding existing implementation

Class names are too generic and hence the responsibility of a class gets wide and complex

Business rules are spread across multiple architectural layers

Too many if / else and switch / cases in classes

Direct usage of implementation classes in parent modules

Page 10: Taming coupling and cohesive beasts

1010

TECHNICAL DEBTSection 5.2 on [5], [6] and [7]

Page 11: Taming coupling and cohesive beasts

1111

“Technical Debt is a wonderful metaphor developed by Ward Cunningham… In this metaphor, doing things the quick and dirty way sets us up with a

technical debt, which is similar to a financial debt. Like a financial debt, the technical debt incurs

interest payments, which come in the form of the extra effort that we have to do in future

development because of the quick and dirty design choice.

- Martin Fowler

Page 12: Taming coupling and cohesive beasts

1212

DESIGN ROTSection 5.3 on [5]

Page 13: Taming coupling and cohesive beasts

1313

“ There are four primary symptoms that tell us that our designs are rotting. They are not orthogonal,

but are related to each other in ways that will become obvious. they are: rigidity, fragility,

immobility, and viscosity.

- Uncle Bob

Page 14: Taming coupling and cohesive beasts

1414

BIG BALL OF MUDVisit the links [2], [3] and [4]

Page 15: Taming coupling and cohesive beasts

1515

QUESTION TIMEOpen your most recent project and search for classes with *util*, *helper*

and *manager*

Page 16: Taming coupling and cohesive beasts

1616

SUFFERINGEssentially leads to

Page 17: Taming coupling and cohesive beasts

1717

SUCH AS

Forcing your team to continuously work long hours.

Burning out your best team members.

High churn rate of resources.

Create psychological divide between development, testing and operations team.

Setting up your team member to just play safe.

Basically, unpleased work environment.

At the worst - completely scrapping the project.

Page 18: Taming coupling and cohesive beasts

1818

BEAST !!!Congratulations!!! You have unleashed the

Page 19: Taming coupling and cohesive beasts

1919

TAME THE BEAST?So, how do we

Page 20: Taming coupling and cohesive beasts

2020

DREAMLets

Page 21: Taming coupling and cohesive beasts

2121

CONFIDENCEWhile embracing change

Page 22: Taming coupling and cohesive beasts

2222

PIVOTThe design with least amount of cascading disruption.

Page 23: Taming coupling and cohesive beasts

2323

UNDERSTANDThe business and the business constrains through

CODE

Page 24: Taming coupling and cohesive beasts

2424

LEHMAN’S LAWIntroducing

Page 25: Taming coupling and cohesive beasts

2525

Second Law.

As a system evolves, its complexity increases unless work is done to maintain

or reduce it.

Specifically,

Page 26: Taming coupling and cohesive beasts

2626

REFACTORINGTHE DESIGN

So the magic ingredient is …

Page 27: Taming coupling and cohesive beasts

2727

PHYSICAL & STRUCTURAL

DESIGN

Specifically,

Page 28: Taming coupling and cohesive beasts

2828

Page 29: Taming coupling and cohesive beasts

2929

Page 30: Taming coupling and cohesive beasts

3030

Page 31: Taming coupling and cohesive beasts

3131

Page 32: Taming coupling and cohesive beasts

3232

Page 33: Taming coupling and cohesive beasts

3333

COHESIVE MODULES

Module behavior should serve a singular purpose

Page 34: Taming coupling and cohesive beasts

3434

Page 35: Taming coupling and cohesive beasts

3535

Page 36: Taming coupling and cohesive beasts

3636

Page 37: Taming coupling and cohesive beasts

3737

Page 38: Taming coupling and cohesive beasts

3838

Page 39: Taming coupling and cohesive beasts

3939

ABSTRACT MODULES

Depend upon the abstract elements of a module.

Page 40: Taming coupling and cohesive beasts

4040

SEPARATE ABSTRACTIONS

Place abstractions and the classes that implement them in separate modules.

Page 41: Taming coupling and cohesive beasts

4141

Page 42: Taming coupling and cohesive beasts

4242

SPEC AND IMPL MODULES

Also fulfills SRP and DIP in SOLID Principles

Leads us to create

Page 43: Taming coupling and cohesive beasts

4343

IMPLEMENTATION FACTORY

Use factories to create a module’s implementation classes.

Page 44: Taming coupling and cohesive beasts

4444

SPRING AND EXTENSIONInjecting extensions in a non-intrusive way.

Page 45: Taming coupling and cohesive beasts

4545

Page 46: Taming coupling and cohesive beasts

4646

MANAGE RELATIONSHIPS

Design module relationships.

Page 47: Taming coupling and cohesive beasts

4747

ACYCLIC RELATIONSHIPS

Module relationships must be acyclic.

Page 48: Taming coupling and cohesive beasts

4848

DDD – BOUNDED CONTEXT

Anti-Corruption Layer

Page 49: Taming coupling and cohesive beasts

4949

ADAPTER ModulesAnd corresponding SPEC and IMPL modules

Page 50: Taming coupling and cohesive beasts

5050

Page 51: Taming coupling and cohesive beasts

5151

DEMO TIME

Page 52: Taming coupling and cohesive beasts

5252

SEAMS OF THE SYSTEM

Expose

Page 53: Taming coupling and cohesive beasts

5353

ALL THE WAY DOWN

Architect

Page 54: Taming coupling and cohesive beasts

5454

MODULARDesign?

Why not start with a

Page 55: Taming coupling and cohesive beasts

5555

RECORDDesign debts, hacks and quick wins

Page 56: Taming coupling and cohesive beasts

5656

REVIEWThe Inventory every six month

Page 57: Taming coupling and cohesive beasts

5757

PLANA separate release for paying the principle

Page 58: Taming coupling and cohesive beasts

5858

BUY-INFrom stakeholders

Get the

Page 59: Taming coupling and cohesive beasts

5959

REFACTORTo Modularity

Page 60: Taming coupling and cohesive beasts

6060

THANK YOU !!!Connect me on twitter at @its_param

Email me at [email protected]

Page 61: Taming coupling and cohesive beasts

6161

Please come.

SPRING CONFERENCE

Page 62: Taming coupling and cohesive beasts

6262

http://panelpicker.sxsw.com/vote/22263

Please share and vote!

UX DESIGN

Page 63: Taming coupling and cohesive beasts

6363

https://medium.com/@its_paramPlease visit.

MY BLOG

Page 64: Taming coupling and cohesive beasts

6464

References

1. http://www.jsjf.demon.co.uk/thesis/Thesis.html

2. http://www.laputan.org/mud/

3. http://www.codinghorror.com/blog/2007/11/the-big-ball-of-mud-and-other-architectural-disasters.html

4. http://stackoverflow.com/questions/1030388/how-to-overcome-the-anti-pattern-big-ball-of-mud

5. http://www.kirkk.com/modularity/2009/12/chapter-5-taming-the-beast/

6. http://en.wikipedia.org/wiki/Technical_debt

7. http://martinfowler.com/bliki/TechnicalDebt.html

8. http://interactiveasp.net/blogs/softwarepsychology/archive/2009/12/23/the-blame-game.aspx