Practical Object-Oriented Design: An Agile Primer Using Ruby
Rate it:
Open Preview
Kindle Notes & Highlights
Read between November 26, 2019 - July 21, 2020
68%
Flag icon
Use Duck Types for behaves-like-a Relationships
68%
Flag icon
Use Composition for has-a Relationships
68%
Flag icon
This is-a versus has-a distinction is at the core of deciding between inheritance and composition.
68%
Flag icon
These techniques are tools, nothing more, and you’ll become a better designer if you practice each of them. Learning to use them properly is a matter of experience and judgment, and one of the best ways to gain experience is to learn from your own mistakes. The key to improving your design skills is to attempt these techniques, accept your errors cheerfully, remain detached from past design decisions, and refactor mercilessly.
68%
Flag icon
Writing changeable code is an art whose practice relies on three different skills.
68%
Flag icon
First, you must understand object-oriented design.
Dawid
Good design preserves maximum flexibility at minimum cost by putting off decisions at every opportunity, deferring commitments until more specific requirements arrive.
68%
Flag icon
Second, you must be skilled at refactoring code.
Dawid
Refactoring is the process of changing a software system in such a way that it does not alter the external behavior of the code yet improves the internal structure.
69%
Flag icon
Finally, the art of writing changeable code requires the ability to write high-value tests.
69%
Flag icon
Well-designed code is easy to change, refactoring is how you change from one design to the next, and tests free you to refactor with impunity.
69%
Flag icon
It is common for programmers who are new to testing to find themselves in the unhappy state where the tests they write do cost more than the value those tests provide and who therefore want to argue about the worth of tests.
69%
Flag icon
Knowing Your Intentions
69%
Flag icon
Finding Bugs
69%
Flag icon
Supplying Documentation
69%
Flag icon
Deferring Design Decisions
69%
Flag icon
Supporting Abstractions
69%
Flag icon
Exposing Design Flaws
Dawid
Tests are the canary in the coal mine; when the design is bad, testing is hard.
69%
Flag icon
Most programmers write too many tests.
70%
Flag icon
Here, then, are the guidelines for what to test: Incoming messages should be tested for the state they return. Outgoing command messages should be tested to ensure they get sent. Outgoing query messages should not be tested.
70%
Flag icon
It is an unfortunate truth that the most complex code is usually written by the least qualified person.
70%
Flag icon
The overcomplicated applications these novices produce should be viewed as triumphs of perseverance; it’s a miracle these applications work at all. The code is hard.
71%
Flag icon
Deleting Unused Interfaces
71%
Flag icon
It’s not really incoming at all, it’s a speculative implementation that reeks of guessing about the future and clearly anticipates requirements that do not exist.
76%
Flag icon
The goal of this section was to prove public interfaces by testing incoming messages. Wheel was cheap to test. The original Gear test was more expensive because it depended on a hidden coupling to Wheel. Replacing that coupling with an injected dependency on Diameterizable isolated the object under test but created a dilemma about whether to inject a real or a fake object.
77%
Flag icon
The rules of thumb for testing private methods are: Never write them, and if you do, never ever test them, unless of course it makes sense to do so. Therefore, be biased against writing these tests but do not fear to do so if this would improve your lot.
81%
Flag icon
Now that you know how to write reusable tests that prove an object correctly plays a role, you can use this technique to reduce the brittleness caused by stubbing.
84%
Flag icon
When you treat test doubles as you would any other role player and test them to prove their correctness, you avoid test brittleness and can stub without fear of consequence.
« Prev 1 2 Next »