Introduction
Lecture Notes for CS 190
Winter 2020
John Ousterhout
Course Background and Goals
- This may be the only course in the world dedicated entirely to software
design:
- How should large systems be structured?
- What does good code look like?
- What is the role of design in the software development process?
- Goal for the class: enhance design awareness
- Change the way you think about programming
- Provide vocabulary for talking about design
- Present a set of principles of software design
- Develop critical skills: recognize good and bad designs (red flags)
Complexity
- Why does design matter? Too hard to build and evolve large software
systems:
- Can't understand how they work
- Can't figure out how to fix bugs or implement new features
- Hard to produce code without bugs (can't predict implications
of a change)
- Complexity: anything related to the structure of a system
that makes it hard to understand and modify the system.
- No-one can fully understand a large software system: can't keep
it all in your mind at once
- What makes systems complicated?
- Lots of little things: complexity is incremental
- Examples: dependencies, inconsistencies, special cases
- Complexity increases as a system ages
- Most important overall goal for design: reduce apparent complexity
- Eliminate complexity
- Hide complexity: modular design
- Decompose large system into pieces that are mostly independent
- Each module is relatively small
- Most coding tasks involve only a few modules
- Allows more functionality before system becomes unmaintainable
- Result: make it easier to work with large systems that have lots
of functionality.
Role of Design in the Software Development Process
- Software design is a continuous process: different from other kinds of
engineering
- Most engineering areas: design is only done at the beginning of
a project
- Early days of software: waterfall model: divide development
into distinct phases: requirements
definition, design, coding, testing, maintenance.
- Problem: can't visualize a large software system well enough
to design it all in advance
- Approaches today tend to be more incremental (e.g. agile
development).
- Eliminate all up-front design?
- Compromise approach works best:
- Design a bit
- Implement and evaluate
- Refactor to fix problems
- Design a bit more, and repeat
- What you learn in earlier phases reduces mistakes in later phases
- Will still make mistakes: must constantly be looking for and
fixing design problems.
Course Structure
- Iteration
- Create a nontrivial application from scratch
- Receive criticism
- Rewrite to fix problems
- Criticism:
- I will read all projects
- You will read each other's projects
- In-class code reviews
- Goal for course: minimize apparent complexity
- Clean, simple, obvious
- Correctness less important (within reason)
- Class organized around 3 projects:
- Projects 1 and 2: Raft protocol for distributed consensus
- Project 1: leader election mechanism, communication
- Project 2:
- Revise, based on code reviews
- Add log mechanism, implement replicated shell
- Project 3: simple bash-like shell
- Work in teams of 2
- Code in C++
- Class format: studio (discussion, interaction):
- Lectures (only a few): around 50 minutes
- Studios (code reviews, exercises, etc.): 80 minutes
- Some classes cancelled to make time for programming
- Class attendance is mandatory
- Grading policy:
- No exams
- Grades based on project work and class participation
- 3 late days
- Office hours
- Piazza for communication
- Class participation is essential
- Giving and receiving criticism is very important
- Expect to receive lots of feedback, may be intense:
- Unlikely that any of you is already a good programmer
- Small details matter
- Keep criticism constructive:
- It's about the code, not the person
- Remember that everyone is learning
- Growth mindset
- Book: read Chapters 1-17 before Friday.
- I'm interested in feedback on the class
- Get started right away!
- Pick partners immediately
- Meet after class
- Send me info: Google ids, GitHub ids
- Read Raft paper, Project 1 writeup, start designing/coding
- Read APOSD Chapters 1-18 before class on Friday
- This week: discuss Raft (read the paper by Wednesday)
- Next week: review material from APOSD