clarify our ideas about what we want the code to do. Automated Tests: "When we find a feature that's difficult to test, we don't just ask ourselves how to test it, but also why is it difficult to test." Steve Freeman, Nat Pryce (Growing Object Oriented Software Guided by Tests - GOOS)
◦ To improve and simplify its design ◦ To remove duplication ◦ To ensure that it clearly expresses what it does • The test suites in the feedback loops protect us against our own mistakes as we improve the code. Automated Tests:
also gives us rapid feedback about the quality of our design ideas - that making code accessible for testing often drives it towards being cleaner and more modular" Steve Freeman, Nat Pryce (GOOS)
single responsibility, and that responsibility entirely encapsulated. 1. "Our heuristic is that we should be able to describe what an object does without using any conjunctions ('and', 'or')" Steve freeman, Nat Pryce (GOOS)
its responsibilities form a meaningful unit (...) a class that parses both dates and URLs is not coherent, because they are unrelated concepts. Think of a machine that washes both clothes and dishes—it’s unlikely to do both well." Steve freeman, Nat Pryce (GOOS)
only the punctuation in a URL is unlikely to be coherent, because it does not represent a whole concept. To get anything done, the programmer will have to find other parsers for protocol, host, resource, and so on. Features with “high” coherence are easier to maintain." Steve freeman, Nat Pryce (GOOS)
things like classes by adding to or building on top of them (using mechanisms like subclassing or polymorphism) rather than modifying their code • In short: If it works, don't touch it" Carlos Blé
both should depend on shared abstractions • Abstractions should not depend on details – instead, details should depend on abstractions. Dependency Inversion Principle