Skip to content
Ameen Abozaid
In reviewJNR-003-L03

Cohesion and coupling

  • Lesson 3 of 7
  • 11 min read
  • Junior
On This Lesson 4 topics

The content for this lesson is written and waiting for review. The outline below shows what it covers. It will be published once it is approved.

In this lesson

judge how well a class is built.

Planned topics

  • Cohesion: do the parts of a class belong together? High cohesion is good.
  • Coupling: how much does one class depend on others? Low coupling is good.
  • Like a workshop: tools for one job in one drawer, and little need to walk between rooms.
  • Reduce coupling: depend on a small interface, not on a concrete class; hide details.
  • A class that does many unrelated things has low cohesion; split it.
Draft outline details

Demonstration

a diagram of CheckoutService linked to five concrete classes, then to two interfaces.

Check your understanding

Which do you want: high or low coupling?

Show answer

Low coupling, high cohesion.

Practice

Apply this lesson with the module's lab, exercises and quiz.

Lab and exercises Quiz

Marking a lesson complete is optional and you can undo it any time. Your progress stays in this browser.

Continue to next lesson

Type to search levels, phases, modules and lessons.