DEV Community

Discussion on: Is testability a reason to change your design?

Collapse
 
n_develop profile image
Lars Richter

Premature optimization is the root of all evil

That's a real classic. :-) And it's so true. I totally agree with your checklist. But in a lot of the before mentioned conversations, there is an argument about "What is an accepted/important/valuable usage of the interface?".

Your first point on the checklist is

1) Is any one going to use extracted interface?

In most (of my) cases there are at least two usages of the interface. The first is the actual implementation. That's the obvious one. And the second usage is the stub/mock/fake (I don't want to start a discussion on the naming here) for the tests. But a lot of people would argue, that the mock-implementation doesn't justify the existence of the interface. And I don't really get that. Why would that implementation of the interface be less important than the first one?

And just one word about your last statement.

Never code for distant future.

Amen.