When writing software we never get directly to a good code design, to a design that minimizes the cost of change. Instead we improve the design of our code by gradually refactoring it. We put into the code the knowledge we learn by experimenting with it. In general, a loose coupled design is better, is less resistant to changes. Knowing patterns of refactoring, and simple heuristics to identify refactoring opportunities increases our efficiency in getting to a good code design.
In this presentation I demonstrate how by refactoring in small steps, by following some simple rules and by applying some simple heuristics of increasing the cohesion of our classes and functions, we can get to a looser coupled design, to a better code design. I will walk you through this process by taking a piece of C# code and work on it during the session, improving it together with you.
4. @ITCAMPRO #ITCAMP15Community Conference for IT Professionals
Low Coupling is GOOD
Loosely coupled
systems are
more
maintainable
Loose coupled
code is easier to
change
5. @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
6. @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
7. @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
8. @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?