Hacker News new | ask | show | jobs
by asianthrowaway 2750 days ago
A good programmer plans ahead.

Edit: of course it is up to individual judgement on a case by case basis, and there are instances were it is obvious that no other concrete implementation of an interface will be required. But otherwise, writing an interface is good practice because it helps safeguard against time consuming future refactoring.

3 comments

This is exactly what YAGNI is meant to counter: the constant tendency of programmers to add speculative extension capabilities that are never used. These add complexity and cognitive overhead. It's a net loss.

Also, people pretend like refactoring is hard. My experience is that refactoring is only hard on the ends of the spectrum, where someone has added all the wrong abstractions, or no abstractions at all. Of the two, I'd prefer the latter, but obviously anything in the middle is usually better.

No. I get why you think this way, as I also used to. Good programmers may think ahead, but they don't build ahead.
> A good programmer plans ahead

The comment above said the opposite, that the future was irrelevant.

These days there are tools that can help in a lot of languages; it's not a time consuming operation to press the Resharper "extract into abstract interface" button.