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:

Your thoughts have gone off track. You’re thinking about what the class might be, rather than what it must be. You were on a mission when you started building that class. Keep on that mission rather than let yourself be distracted for even a moment.

Your time is precious. Hone your sense of progress to focus on the real task, not just on banging out code.

You might not need it after all. If that happens, the time you spend implementing the method will be wasted; the time everyone else spends reading it will be wasted; the space it takes up will be wasted.

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.