You’re NOT gonna need it!

Often you will be building some class and you’ll hear yourself saying "We’re going to need...".

Resist that impulse, every time. Always implement things when you actually need them, never when you just foresee that you need them. Here’s why:

You find that you need a getter for some instance variable. Fine, write it. Don’t write the setter because "we’re going to need it". Don’t write getters for other instance variables because "we’re going to need them".

The best way to implement code quickly is to implement less of it. The best way to have fewer bugs is to implement less code.

You’re not gonna need it!


1997, 1998, Ronald E Jeffries
ronjeffries@acm.org
http://www.xprogramming.com