Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Achieving Low Coupling by Refactoring Towards Higher Cohesion

458 views

Published on

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.

Published in: Engineering
  • Be the first to comment

  • Be the first to like this

Achieving Low Coupling by Refactoring Towards Higher Cohesion

  1. 1. @ITCAMPRO #ITCAMP15Community Conference for IT Professionals Achieving Low Coupling by Refactoring Towards Higher Cohesion Florin Coros www.rabs.ro | www.iquarc.com florin.coros@rabs.ro @florincoros blog.iquarc.com/florin
  2. 2. @ITCAMPRO #ITCAMP15Community Conference for IT Professionals Many thanks to our sponsors & partners! GOLD SILVER PARTNERS PLATINUM
  3. 3. @ITCAMPRO #ITCAMP15Community Conference for IT Professionals About me Co-Founder Software Architect @florincoros Founder & Partner
  4. 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. 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. 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. 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. 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?
  9. 9. @ITCAMPRO #ITCAMP15Community Conference for IT Professionals • Small Steps • Follow a Recipe • Mechanized Refactor
  10. 10. @ITCAMPRO #ITCAMP15Community Conference for IT Professionals Dependencies
  11. 11. @ITCAMPRO #ITCAMP15Community Conference for IT Professionals Refactoring Recipe: Step 1. Reduce Parameters Reduce Functions Parameters
  12. 12. @ITCAMPRO #ITCAMP15Community Conference for IT Professionals Refactoring Recipe: Step 2. Increase Class Cohesion
  13. 13. @ITCAMPRO #ITCAMP15Community Conference for IT Professionals Refactoring Recipe: Step 3. Reduce Class Dependencies
  14. 14. @ITCAMPRO #ITCAMP15Community Conference for IT Professionals Refactoring Recipe: Step 3. Reduce Class Dependencies
  15. 15. @ITCAMPRO #ITCAMP15Community Conference for IT Professionals Code Demo www.github.com iQuarc Code-Design-Training LessonsSamples Lesson7 CohesionCoupling
  16. 16. @ITCAMPRO #ITCAMP15Community Conference for IT Professionals Thank You!
  17. 17. @ITCAMPRO #ITCAMP15Community Conference for IT Professionals Many thanks to our sponsors & partners! GOLD SILVER PARTNERS PLATINUM

×