achieving low coupling by refactoring towards higher cohesion

17
@ITCAMPRO #ITCAMP15 Community Conference for IT Professionals Achieving Low Coupling by Refactoring Towards Higher Cohesion Florin Coros www.rabs.ro | www.iquarc.com [email protected] @florincoros blog.iquarc.com/florin

Upload: florin-coros

Post on 19-Jan-2017

368 views

Category:

Engineering


0 download

TRANSCRIPT

@ITCAMPRO #ITCAMP15Community Conference for IT Professionals

Achieving Low Coupling by

Refactoring Towards

Higher Cohesion

Florin Coros

www.rabs.ro | www.iquarc.com

[email protected]

@florincoros

blog.iquarc.com/florin

@ITCAMPRO #ITCAMP15Community Conference for IT Professionals

Many thanks to our sponsors & partners!

GOLD

SILVER

PARTNERS

PLATINUM

@ITCAMPRO #ITCAMP15Community Conference for IT Professionals

About me

Co-Founder

Software Architect@florincoros

Founder & Partner

@ITCAMPRO #ITCAMP15Community Conference for IT Professionals

Low Coupling is GOOD

Loosely coupled systems are

more maintainable

Loose coupled code is easier to

change

@ITCAMPRO #ITCAMP15Community Conference for IT Professionals

Separation of Concerns is what we NEED

SoC, our single chance to manage

complexity of software

Easier to address one concern at

the time, in isolation

The end goal of Design Pattern and Principles

@ITCAMPRO #ITCAMP15Community Conference for IT Professionals

High Cohesion and Loose Coupling go hand in hand

A class has high cohesion, when

most of its fields are used by most of its

functions

High cohesive classes are

loosely coupled

Loosely coupled classes have high

cohesion

@ITCAMPRO #ITCAMP15Community Conference for IT Professionals

From Practices to Code

High cohesive classes are

loosely coupled

Loose coupled code is easier

to change

The end goal of Design Pattern and Principles

@ITCAMPRO #ITCAMP15Community Conference for IT Professionals

Do we get to a code design which is Loosely

Coupled and has a good Separation of Concerns

from the start?

Most probably NO

How we get to good code design?

@ITCAMPRO #ITCAMP15Community Conference for IT Professionals

• Small Steps

• Follow a Recipe

• Mechanized

Refactor

@ITCAMPRO #ITCAMP15Community Conference for IT Professionals

Dependencies

@ITCAMPRO #ITCAMP15Community Conference for IT Professionals

Refactoring Recipe: Step 1. Reduce Parameters

Reduce Functions Parameters

@ITCAMPRO #ITCAMP15Community Conference for IT Professionals

Refactoring Recipe: Step 2. Increase Class Cohesion

@ITCAMPRO #ITCAMP15Community Conference for IT Professionals

Refactoring Recipe: Step 3. Reduce Class Dependencies

@ITCAMPRO #ITCAMP15Community Conference for IT Professionals

Refactoring Recipe: Step 3. Reduce Class Dependencies

@ITCAMPRO #ITCAMP15Community Conference for IT Professionals

Thank You!

@ITCAMPRO #ITCAMP15Community Conference for IT Professionals

Many thanks to our sponsors & partners!

GOLD

SILVER

PARTNERS

PLATINUM