Skip to the guide

Practice: Design principles

MixedPractice3 pages

Here are eight questions on the design principles: one reason to change, adding features as new code, subclasses that keep their promises, small interfaces, passing dependencies in, talking only to the objects you hold, one owner for each piece of knowledge, and designs a test can control. Most of them show you a class or a design and ask what you would change. Principles are guidance, not laws, so a reasoned "I wouldn't apply it here" can be a strong answer. The last question puts the whole section together on a small design.

How to use this page. Set a timer for each question, and answer out loud or on paper before opening anything. Open a hint only if you have been stuck for more than a minute. When you are done, open Check your answer, read the worked answer and the list of what a strong answer covers, and compare them with yours. If yours missed most of it, reread the guide the question practises and try again in a day or two.