0

As I understand YAGNI says that we need to extract an interface only if we need. So if we don't need polymorphism and have only one implementation right now we don't need use interface. But DIP says:

A. High-level modules should not depend on low-level modules. Both should depend on abstractions.

B. Abstractions should not depend on details. Details should depend on abstractions.

Looks like some discrepancy between YAGNI and option B. of DIP. Also if we want to apply OCP we need to invert the control of dependency and extract abstraction to have ability to extend a type without modifications of that type.

Also some technologies require to extract an abstraction to have ability to unit test the type clients. But e.g. in java we don't need it. So I want to know do I need to extract an abstraction if I have only one implementation right now?

Cody Gray
  • 230,875
  • 49
  • 477
  • 553
Serg046
  • 933
  • 11
  • 35
  • 1
    The question in bold is a duplicate of many religious debates across SO, [Programmers.SE](http://programmers.stackexchange.com/questions/150045/), and numerous tech blogs. Specifically regarding DIP, see http://stackoverflow.com/questions/28773904/. – jaco0646 Aug 17 '16 at 14:42
  • Yes, good thread, thank you. But I still don't know whether the DIP breaks YAGNI... – Serg046 Aug 17 '16 at 15:17

0 Answers0