Bitpath

Lesson 2 · Unit 04

Where code lives

Cohesion, coupling and which way the arrows point

12 exercisesabout 3 min

What you practise

  • Cohesion and coupling, which way dependencies point, a small public surface, moving a function to the data it uses

Try a question from this lesson

Pick one

The way tax is worked out is about to change. This module holds 47 functions. What does its name tell you about where to look?

module: utils
  format_date()     parse_csv()
  send_email()      tax_for()
  resize_image()    retry()
  ... 41 more

The idea

Concept cards are short on purpose. In the app they appear between questions, after you have met the idea.

Concept

Cohesion and coupling

Cohesion: the things inside a module belong together and change for the same reason.

Coupling: how much one module has to know about another.

Aim for high cohesion and low coupling. Most changes then touch one file, and you can understand that file without reading the rest.

high cohesion      low cohesion

module: tax        module: utils
  rate_for()         tax_for()
  tax_for()          send_email()
  round_tax()        resize_image()

10 more exercises in the app

  • 4× multiple choice
  • 2× type the answer
  • 1× fill the blanks
  • 2× true or false
  • 1× match the pairs

Bitpath is an iOS app in development. Join the waitlist and you get one email when it is ready to try.

One email when Bitpath is ready to try. Nothing else. Privacy