Live data from Hacker News

Solid Relevance

blog.cleancoder.com

1–10 of 55 posts

Re: Solid Relevance

#2
There's 2 approaches to programming:

- make it easy to extend (lets's call it SOLID in this context)

- make it easy to rewrite (let's call it KISS)

OO developers think that the first approach is The Only Way but both can be right, especially with high-level declarative languages and with tasks small enough (relative to the language expressive power).

SOLID makes it easier to modify programs (in predetermined directions) without understanding the whole.

KISS makes it easier to understand the whole program.

SOLID accumulates inefficiencies over time because people program with tunnel vision.

KISS takes longer to modify as it grows and eventually exceeds the capacity of human brain.

SOLID is mostly OO, KISS is mostly declarative.

If you want to feel safe changing code unit tests are nice, best practices and design patterns are nice too, good architecture is appreciated. But the best is just to understand everything that happens. Only then truly fearless programming is possible.

Once you go big enough you have to use SOLID but before that it's a cost.

Re: Solid Relevance

#3
post #2

There's 2 approaches to programming: - make it easy to extend (lets's call it SOLID in this context) - make it easy to rewrite (let's call it KISS) OO developers think that the first approach is The Only Way but both can be right, especially with high-level declarative languages and with tasks small enough (relative to the language expressive power). SOLID makes it easier to modify programs (in predetermined directio…

> SOLID makes it easier to modify programs (in predetermined directions) without understanding the whole.

In my experience, in predetermined directions is almost never the direction the piece of code needs to evolve. Maybe I'm bad at reasoning about the future changes, but I'd guess that most people are utterly bad about this.

This makes OCP more like an ideal to be aspired to, and beaten with when one inevitably fails.

Re: Solid Relevance

#4
post #2

There's 2 approaches to programming: - make it easy to extend (lets's call it SOLID in this context) - make it easy to rewrite (let's call it KISS) OO developers think that the first approach is The Only Way but both can be right, especially with high-level declarative languages and with tasks small enough (relative to the language expressive power). SOLID makes it easier to modify programs (in predetermined directio…

> But the best is just to understand everything that happens.

Agreed, but unless you have written all the code yourself then this is hard to do. We have to be able to black-box things in order to manage complexity and make progress quickly. For this SOLID helps but if it is applied a too fine a granularity then it can make things worse (and I think micro testing things with mocks etc can cause this)

"There is no theoretical reason that anything is hard to change about software. If you pick any one aspect of software then you can make it easy to change, but we don’t know how to make everything easy to change. Making something easy to change makes the overall system a little more complex, and making everything easy to change makes the entire system very complex. Complexity is what makes software hard to change. That, and duplication."

https://martinfowler.com/ieeeSoftware/whoNeedsArchitect.pdf

Re: Solid Relevance

#5
post #2

There's 2 approaches to programming: - make it easy to extend (lets's call it SOLID in this context) - make it easy to rewrite (let's call it KISS) OO developers think that the first approach is The Only Way but both can be right, especially with high-level declarative languages and with tasks small enough (relative to the language expressive power). SOLID makes it easier to modify programs (in predetermined directio…

I can see how SOLID and OOP seem to be related, but the principals of SOLID can (and IMO should) be applied to FP as well. In fact one of the clarifications in Uncle Bob’s letter hints at this, by expressing that substitution is about subtypes, not inheritance.

This is of course common in statically typed FP languages like Haskell (or FP approaches in statically types imperative languages like TypeScript, Swift, so on). But even in dynamic languages like Clojure, substitution of subtypes of a given interface is pervasive; I would even say it’s foundational to the language’s core concepts.

I’d even go further to say that FP languages and approaches are much more likely to guide developers toward SOLID naturally than imperative languages and approaches.

Re: Solid Relevance

#6
Software is still if statements, while loops, and assignment statements — Sequence, Selection, and Iteration.

That seems an extremely narrow view of modern programming. But then isn't this the same man who made the claim about there not being any new programming languages left to find?

Re: Solid Relevance

#7

Software is still if statements, while loops, and assignment statements — Sequence, Selection, and Iteration. That seems an extremely narrow view of modern programming. But then isn't this the same man who made the claim about there not being any new programming languages left to find?

Curious, what new has been found?

Re: Solid Relevance

#8
SOLID is just a random arbitrary acronym about some principles that are somewhat obvious. However most people don't fully understand these principles deeply. What happens is if you are using OOP you are not using SOLID to its full extent. Ironic that SOLID comes from OOP.

Either way SOLID are arbitrary rules of thumb. Grouped together arbitrarily to spell out SOLID and kind of maybe sort of right depending on your opinion.

   1. SRP. Gather together the things that change for the same reasons. Separate things that change for different reasons.
I disagree. Unless this thing is talking about namespacing which is more of an aesthetic/psychological thing... You should not organize your program this way where logic of one thing is tied with the logic of another thing. All things should be ungrouped as much as possible.

You should also separate all things that "change" and all things that don't "change" and try to keep the things that "change" as small as possible.

All logical modules in your program should be separated as much as possible at the lowest layer, nothing should be grouped... and higher layers should be compositions of lower layers. But the basis of your program at the lowest layer: everything should be separated and nothing should be grouped.

In other words use combinators as MUCH as possible. OOP's promotion of methods that operate on shared mutable external scope actually prevent you from doing this.

  2. A Module should be open for extension but closed for modification.
Agreed. The problem is if your program is OOP your modules are objects which group methods together through shared mutable state. It means that you cannot extend one method without modifying the entire object.

So basically OOP practitioners can never modify an addOne method into addTwo. They can't even add an addTwo method into the object as that constitutes modification. What they can do is inject that entire object into another object. Either do this or use inheritance which OOP says is just bad.

Instead. Use combinators. You have an addOne combinator? Create an addTwo combinator. Recompose your combinators to form the higher level logic you wanted.

  3. A program that uses an interface must not be confused by an implementation of that interface.
Yeah I mean sure. Don't have your flatten Function be able to operate on an integer.

  4. Keep interfaces small so that users don’t end up depending on things they don’t need.
Agreed the problem is, the definition of an object in OOP usually ties muteable state and logic together. Your average object has a getter and setter which are tied together by external scope, so by definition OOP ties together things that shouldn't belong together. You are not keeping your interfaces small.... by definition it is already too big.

If you defined the logic as I said above separating state changes away from combinators you'd have even smaller interfaces. One for changing state. And the other logic is stateless.

  5. Dependency inversion principle.
I mean yeah. Write your logic in layers. The problem is OOP people only use this principle at the module level.

The better way to program is to have all your methods follow the dependency inversion principle. You can't do this if methods are modifying external scope shared by another method. Use combinators and by definition every sector of your program is following this principle not just "modules"

Re: Solid Relevance

#9
post #2

There's 2 approaches to programming: - make it easy to extend (lets's call it SOLID in this context) - make it easy to rewrite (let's call it KISS) OO developers think that the first approach is The Only Way but both can be right, especially with high-level declarative languages and with tasks small enough (relative to the language expressive power). SOLID makes it easier to modify programs (in predetermined directio…

> But the best is just to understand everything that happens. Agreed, but unless you have written all the code yourself then this is hard to do. We have to be able to black-box things in order to manage complexity and make progress quickly. For this SOLID helps but if it is applied a too fine a granularity then it can make things worse (and I think micro testing things with mocks etc can cause this) "There is no theo…

I disagree with Martin very much. Programs can be made easy to change without introducing complex OOP abstractions.

There is a simple rule that Martin fails to ever mention.

Use combinators as much as possible and segregate as much logic as possible from IO. That's it.

Re: Solid Relevance

#10
post #2

There's 2 approaches to programming: - make it easy to extend (lets's call it SOLID in this context) - make it easy to rewrite (let's call it KISS) OO developers think that the first approach is The Only Way but both can be right, especially with high-level declarative languages and with tasks small enough (relative to the language expressive power). SOLID makes it easier to modify programs (in predetermined directio…

I can see how SOLID and OOP seem to be related, but the principals of SOLID can (and IMO should) be applied to FP as well. In fact one of the clarifications in Uncle Bob’s letter hints at this, by expressing that substitution is about subtypes, not inheritance. This is of course common in statically typed FP languages like Haskell (or FP approaches in statically types imperative languages like TypeScript, Swift, so o…

I feel that SOLID doesn't even work well with OOP. Overall it's just saying "be more modular" in a programming paradigm that's one of the least modular styles ever created.
Post reply on HN