Travis Pett

10%
Flag icon
Cog becomes the result of a message send. Implementing this method changes cog from data (which is referenced all over) to behavior (which is defined once). If the @cog instance variable is referred to ten times and it suddenly needs to be adjusted, the code will need many changes. However, if @cog is wrapped in a method, you can change what cog means by implementing your own version of the method.
Travis Pett
Being able to add logic to an accessor instead of having to add logic everywhere an ivar is used really saves time.
Practical Object-Oriented Design: An Agile Primer Using Ruby
Rate this book
Clear rating
Open Preview