| ▲ | ghosty141 5 hours ago |
| What's the problem with SOLID? It's very very rare that I see a case where going against SOLID leads to better design. |
|
| ▲ | GuB-42 4 hours ago | parent | next [-] |
| SOLID tend to encourage premature abstraction, which is a root of evil that is more relevant today than optimization. SOLID isn't bad, but like the idea of premature optimization, it can easily lead you into the wrong direction. You know how people make fun of enterprise code all the time, that's what you get when you take SOLID too far. In practice, it tends to lead to a proliferation of interfaces, which is not only bad for performance but also result in code that is hard to follow. When you see a call through an interface, you don't know what code will be run unless you know how the object is initialized. |
|
| ▲ | sroussey 4 hours ago | parent | prev | next [-] |
| In a way, SOLID is premature optimization. You are optimizing abstractions before knowing how the code is used in practice. Lots of code will be written and never changed again, but a minority will see changes quite a bit. Concentrate there. Like you don't need to optimize things that aren't in hot code (usually, omg experience will tell you that all rules have exceptions, including the exceptions). |
| |
| ▲ | ghosty141 3 hours ago | parent [-] | | > Lots of code will be written and never changed again, but a minority will see changes quite a bit. Concentrate there I think the most important principle above all is knowing when not to stick to them. For example if I know a piece of code is just some "dead end" in the application that almost nothing depends on then there is little point optimizing it (in an architectural and performance sense). But if I'm writing a core part of an application that will have lots of ties to the rest, it totally does make sense keeping an eye on SOLID for example. I think the real error is taking these at face value and not factoring in the rest of your problem domain. It's way too simple to think SOLID = good, else bad. |
|
|
| ▲ | dzjkb 5 hours ago | parent | prev | next [-] |
| here's a nice critique of SOLID principles: https://www.tedinski.com/2019/04/02/solid-critique.html |
| |
| ▲ | newsoftheday 4 hours ago | parent | next [-] | | They start by indicating people don't understand, “A module should have only one reason to change.”. Reading more of that article, it's clear the author doesn't understand much about software engineering and sounds more like a researcher who just graduated from putting together 2+2. | | |
| ▲ | segmondy 4 hours ago | parent [-] | | The great thing bout the net is also it's biggest problem. Anyone can write a blog and if it looks nice, sounds polished they could sway a large group. I roll my eyes so strong at folks that reject SOLID principles and design patterns. | | |
| ▲ | tracker1 4 hours ago | parent | next [-] | | Something, something, wrong abstractions are worse than no abstractions. SOLID approaches aren't free... beyond that keeping code closer together by task/area is another approach. I'm not a fan of premature abstraction, and definitely prefer that code that relates to a feature live closer together as opposed to by the type of class or functional domain space. For that matter, I think it's perfectly fine for a web endpoint handler to make and return a simple database query directly without 8 layers of interfaces/classes in between. Beyond that, there are other approaches to software development that go beyond typical OOP practices. Something, something, everything looks like a nail. The issues that I have with SOLID/CLEAN/ONION is that they tend to lead to inscrutable code bases that take an exponentially long amount of time for anyone to come close to learning and understanding... Let alone the decades of cruft and dead code paths that nobody bothered to clean up along the way. The longest lived applications I've ever experienced tend to be either the simplest, easiest to replace or the most byzantine complex monstrosities... and I know which I'd rather work on and support. After three decades I tend to prioritize KISS/YAGNI over anything else... not that there aren't times where certain patterns are needed, so much as that there are more times where they aren't. I've worked on one, singular, one application in three decades where the abstractions that tend to proliferate in SOLID/CLEAN/ONION actually made sense... it was a commercial application deployed to various govt agencies that had to support MS-SQL, Oracle and DB2 backends. Every, other, time I've seen an excess of database and interface abstractions have been instances that would have been better solved in other, less performance impacting ways. If you only have a single concrete implementation of an interface, you probably don't need that interface... You can inherit/override the class directly for testing. And don't get me started on keeping unit tests in a completely separate project... .Net actually makes it painful to put your tests with your implementation code. It's one of my few actual critiques about the framework itself, not just how it's used/abused. | |
| ▲ | f1shy 3 hours ago | parent | prev [-] | | I have seen way too often, advocates of SOLID and patterns to have religious arguments: I don’t like it. That being said, I think there is nothing bad in SOLID, as long as treated as principles and not religious dogmas.
About patterns, I cannot really say as much positive. They are not bad per-se. But I’ve seen they have made lots of harm. In the gang of 4 book, in the preface, I think, says something like “this list is neither exhaustive, nor complete, and often inadequate” the problem is every single person I know who was exposed to the book, try to hammer every problem into one pattern (in the sense of [1]). Also insist in using the name everywhere like “facade_blabla” IMHO the pattern may be Façade, but putting that through the names of all classes and methods, is not good design. [1] https://github.com/EnterpriseQualityCoding/FizzBuzzEnterpris... | | |
| ▲ | ghosty141 3 hours ago | parent [-] | | > That being said, I think there is nothing bad in SOLID, as long as treated as principles and not religious dogmas This should be the header of the website. I think the core of all these arguments is people thinking they ARE laws that must be followed no matter what. And in that case, yeah that won't work. |
|
|
| |
| ▲ | gavmor 3 hours ago | parent | prev | next [-] | | This doesn't seem to be a critique of the principles so much as a critique of their phrasing. Even his "critique" of Demeter is, essentially, that it focuses on an inconsequential aspect of dysfunction—method chaining—which I consider to be just one sme that leads to the larger principle which—and we, apparently, both agree on this—is interface design. | |
| ▲ | 4 hours ago | parent | prev [-] | | [deleted] |
|
|
| ▲ | someguyiguess 5 hours ago | parent | prev | next [-] |
| It only applies to the object oriented programming paradigm |
| |
| ▲ | mrkeen 3 hours ago | parent | next [-] | | Negative. The only part of SOLID that is perhaps OO-only is Liskov Substitution. L is still a good idea, but without object-inheritance, there's less chance of shooting yourself in the foot. | |
| ▲ | marcosdumay 4 hours ago | parent | prev | next [-] | | That's understating the problem. It mandates OOP. If you follow SOLID, you'll write OOP only, with always present inheritance chains, factories for everything, and no clear relation between parameters and the procedures that use them. | |
| ▲ | Exoristos 4 hours ago | parent | prev [-] | | This is only superficially true. Here's a fair discussion that could serve as a counterpoint: https://medium.com/@ignatovich.dm/applying-solid-principles-... |
|
|
| ▲ | paulddraper 3 hours ago | parent | prev [-] |
| It causes excessive abstraction, and more verbose code. L and I are both pretty reasonable. But S and D can easily be taken to excess. And O seems to suggest OO-style polymorphism instead of ADTs. |
| |
| ▲ | ghosty141 3 hours ago | parent [-] | | This is similar to my view. All these "laws" should alwaye be used as guidance not as actual laws. Same with O. I think its good advice to design software so adding features that are orthogonal to other features don't require modifying much code. That's how I view it. You should design your application such that extension involves little modifying of existing code as long as it's not necessary from a behavior or architectural standpoint. | | |
| ▲ | SAI_Peregrinus an hour ago | parent [-] | | Of course you can do that & still make a mess. E.g. by deciding that all your behavior will be "configurable" by coding inside strings in a YAML file, and what YAML files you load at runtime determine which features you get. Sure, they might conflict, but that's the fault of whoever wrote that "configuration" YAML. (Replace YAML with XML for a previous era version of this bad idea). |
|
|