27.5 Summary, Exercises

Summary

Good code is more than just working code.

Code (and complexity) scales with functionality.

Practice good design principles in your classes!

The real world is ambiguous; you must define the problem and select the solution given tradeoffs of options.

Exercises

Note that since this chapter is more about design principles than actual content, the exercises merely check factual understanding of lecture material. We encourage you to reflect on the software engineering principles discussed as you work on your own projects.

  1. What are two ways to manage complexity?

  2. What is the difference between strategic and tactical programming? Which is better for managing complexity?

Problem 1

Make code simpler and more obvious. Eliminate special cases and avoid repetition. Make code as general and parsimonious as possible.

Encapsulate code into modules. Every module should have a specific purpose. Programmers and users can subsequently use other modules in their design, without having to understand how these modules work.

Problem 2

Tactical programming focuses on getting something to work, instead of focusing on overall design.

In contrast, strategic programming involves planning ahead and selecting from multiple possible implmentations for the cleanest possible solution. Strategic programming requires thinking about possible future changes and emphasizing code quality.

For managing complexity, strategic programming is more effective. Tactical programming introduces complexity with small fixes and patches over time, whereas strategic programming aims to eliminate these complexities by changing the underlying design.

Last updated