Skip to content

Unit 1 — Design in the small

Weeks 1–5. Reading code you didn't write, naming what's wrong with it, and changing it without breaking it.

This unit explores how to measure cost of change, identify code elements that contribute to it, and how to evolve code to make change easier.

Lectures

LectureWhat it answersReadings
The cost of changeWhy does change cost anything?What is Software Engineering · Analytical Code Design
Measuring a changeHow big was that change — and which dimension actually hurts?Cost of Change
Cohesion & connascenceWhat belongs together, and what kind of agreement makes change hard?Change Difficulty
Refactoring as a disciplineHow do I change it safely?Refactoring
Polymorphism & LSPWhen is it safe to substitute one thing for another?Design Principles (SOLID)
What makes code testableWhy does code resist testing?Testability
Test doubles & dependency inversionHow do I test something I didn't construct?Testability · Design Principles (SOLID)

Slides are posted on the schedule as we go.

By the end of this unit you can

Measure a change

  • Describe a change in terms of magnitude and footprint, given a diff, and say why footprint is the expensive dimension
  • Identify code smells in real code — scattered changes, divergent changes, feature envy

Name what you found

  • Identify the factors that determine how cohesive code is
  • Use the three axes of coupling — strength, degree, locality — to describe how two pieces of code are related and how that affects cost of change
  • Identify five kinds of connascence (name, type, value, position, algorithm) in unfamiliar code

Make it testable

  • Given a class and a test, determine its controllability and observability.
  • Apply dependency inversion to enable test doules (mocks and fakes)
  • Adapt code to be able to easily use mocks and fakes to address testability concerns

Safely evolve code

  • Use a meticulous process to minimize errors when evolving code
  • Articulate how testing enables this process

Course reader licensed under CC BY-SA 3.0.