YAGNI says until needed. I say: if you use Test Driven Design, then I think that you should use tests to dictate the design.
As a specific example, I am writing a virtual machine that can run embedded bytecode. The interface of the outside world is the Runtime interface. The client uses it to run functions by name, global queries, etc.
Implementing Runtime requires many different components, one of which is VirtualMachine, which controls access to the stack, memory, registers, etc.
In unit testing, the idea is to take each object and test it separately from the rest of the world. However, the runtime depends on VirtualMachine. To disconnect a virtual machine from Runtime, it needs to be mocked. This means that VirtualMachine must be derived from an interface common to MockVirtualMachine.
Consequently, tests dictate that VirtualMachine should be inherited from the interface. I did not need to do this until then.
source share