Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

21
  • 27
    My first introduction to SOLID was about a 15 years ago on a new system we were building. We all drank the kool aid man. If anybody mentioned anything that sounded like YAGNI, we were like "Pfffft... plebeian". I had the honor (horror?) of watching that system evolve over the course of the next decade. It became an unwieldy mess that no one could understand, not even we founders. Architects love SOLID. People who actually earn their living love YAGNI. Neither is perfect, but YAGNI's closer to perfect, and should be your default if you don't know what you're doing. :-) Commented Feb 25, 2015 at 21:09
  • 13
    @NWard Yeah, we did that on a project. Went nuts with it. Now our tests are impossible to read or maintain, in part because of over-mocking. On top of that, because of the dependency injection, it's a pain in the rear to navigate through the code when you're trying to figure something out. SOLID isn't a silver bullet. YAGNI isn't a silver bullet. Automated testing isn't a silver bullet. Nothing can save you from doing the hard work of thinking about what you're doing and making decisions about whether it's going to help or hinder your work or someone else's. Commented Feb 25, 2015 at 23:26
  • 27
    A lot of anti-SOLID sentiment here. SOLID and YAGNI are not two ends of a spectrum. They're like the X and Y coordinates on a chart. A good system has very little superfluous code (YAGNI) AND follows the SOLID principles. Commented Feb 26, 2015 at 0:38
  • 36
    Meh, (a) I disagree that SOLID = enterprisey and (b) the whole point of SOLID is that we tend to be extremely poor forecasters of what will be needed. I have to agree with @Stephen here. YAGNI says that we should not try to anticipate future requirements that aren't clearly spelled out today. SOLID says that we should expect the design to evolve over time and apply certain simple techniques to facilitate it. They are not mutually exclusive; both are techniques for adapting to changing requirements. The real problems happen when you try to design for unclear or very distant requirements. Commented Feb 26, 2015 at 4:53
  • 11
    "you can easily swap reading from a file for a a network stream" -- this is a good example where an over-simplified description of DI leads people astray. People sometimes think (in effect), "this method will use a File, so instead it'll take an IFile, job done". Then they can't easily substitute a network stream, because they over-demanded the interface, and there are operations in IFile the method doesn't even use, that don't apply to sockets, so a socket can't implement IFile. One of the things DI isn't a silver bullet for, is inventing the right abstractions (interfaces) :-) Commented Feb 26, 2015 at 10:29