Complexity and Dependencies

Lecture Notes for CS 190
Spring 2016
John Ousterhout

  • Programs evolve continuously:
    • Can't get the architecture right the first time
      • Waterfall approach doesn't work
    • Additional feature needs arise over time
  • It's not good enough to write code that works
    • Most important metric: how easy is it to evolve this code?
      • Enable continual improvements over a 10-20 year lifetime
      • Improvements will be made by people who weren't involved in the original construction
    • Code must also be "beautiful"
  • Complexity: things that make it hard to evolve software
    • Dependencies: one piece of code depends on another
      • Can't modify pieces independently
    • Obscurity: not clear how things work or why the code is the way it is
  • Dependencies make software evolution hard in 3 ways:
    • A conceptually simple change may require many code modifications
    • Programmer needs to have a lot of information in their mind to make a change correctly
    • It's not clear what the dependencies are
  • Dependencies accumulate
    • No one thing makes a system complicated
    • It's an accumulation of thousands of small dependencies over time
    • Once complexity arises, hard to eliminate
    • Typical (wrong) developer philosophy: "as long as I don't make things much more complicated, it's OK"
    • Must adopt a zero-tolerance attitude everything matters.
      • Must sweat the small stuff
  • Real-world pressures encourage complexity
    • Fastest way to make progress in the short term is not to worry about complexity.
    • To reduce complexity, must invest extra time now, but the biggest benefits don't come until the future.
    • Must compromise: zero tolerance for complexity probably not viable.
    • Focus on most important things:
      • Good interface design
      • Documentation more important for interfaces than internals
    • Create a budget for refactoring and cleanup
    • Find ways to teach new employees how to write simple code (e.g. code reviews)
    • Investment to control complexity pays for itself relatively quickly (6-12 months?)
      • Without care, complexity builds up very fast
      • Once this happens, development becomes much more expensive, would have been cheaper to invest early on
  • For this class: zero tolerance for complexity
    • Goal: learn how to make things simple