Hacker News new | ask | show | jobs
by stiff 4425 days ago
While he might understand what he is talking about, based on a corpus of experience, people who learn about this "principle" as they learn to program do not typically understand it and tend to draw only the wrong conclusions from it. What makes for coupling, and how to avoid it, you simply learn with a lot of practice, and there are not many clearcut guidelines you can formulate, it all varies depending on the problem. At best you can read SICP and see how they decouple everything by doing lots of data-driving and dynamic dispatch and things of this sort.

This is too vague to be a "principle", and only causes confusion. It is about as precise, and as useful, as the "write good code" principle.

2 comments

A lot of people seem to chafe at these principles because they convey truths about a intangible reality they may not even be able to perceive. They only see more work for little payoff. They don't have the body of knowledge and experience (nor the intuition) to know when when to abstract more. We're also in a post-enterprise era, where any sort of deliberate design is often mocked by way of strawman AbstractComposerFactorySingleton references. Rhetoric masquerades as honest intellectual debate for self-promotional purposes.

I consider myself fortunate to have written enough C++ to learn coupling and cohesion. When you screw these up in C++, you pay for it, over and over, through increased compile times and link times.

The principles apply to any language. I wrote a lot of C++ and today I write a lot of Python and the principles of building solid maintainable systems hold the same for both.

I think there are other factor at work here:

- The size of the project. I think most code written today is in the context of tiny systems, e.g. a bit of Javascript that goes with a single web page or some trivial backend code within an existing framework.

- The life cycle of the project. Most software projects have a short life time. This is for various reasons, some of them technical, some of them business related.

- You pay for bad design much farther down the road so it's harder for people to see the causation.

- The investment of individual engineers. If you move from one startup to the other every year you may not care that much about principles that will affect maintainability. You should but a lot of people don't. By the time coupling matters you'll already be hacking somewhere else. Being disconnected from the results of your work creates a difficulty in understanding design principles.

- Not Invented Here. People generally aren't open to receiving lessons from other people's experience. Learning often has to happen through individual experience.

I don't think there are many successful, large, long term, software projects where everything is a jumbled mess with no design intent and everything coupled with everything.

They don't chafe because they convey truths about a intangible reality they may not even be able to perceive. They chafe because nothing is actually being conveyed. Its a bunch of words removed from any actual meaning - from the concrete problems that caused the person to arrive to the truth being "conveyed". They're like the conclusion part of an essay with all the rest left out. They tell nothing to people that don't already know, and nothing new to people that do.

Its no wonder people either tend to discard them or to apply them incorrectly.

I remember first hearing about Uncle Bob's principles and the GoF patterns in a lunch meeting a company in town (Rogue Wave Software) held for anyone interested. When I heard those guys talking about object oriented design and system architecture in general I could just listen in awe. This was before the AbstractFactoryFactory antipattern (Java was just starting) and I thought if I could just gain the level of understanding the RW guys had I'd be golden.

15 years later I've written enough software to understand the principles but no amount of study got me there, just lots of practice and fixing my own mistakes.

Yeah, the actual context is rarely ever delivered. And that matters a lot. Sometimes I wonder how well it would be received, though. Not to mention many books on software engineering tend to be written in a more abstract style than most blog posts. I'm not sure of the precedent for this is there; it would certainly help.

The GoF book does a decent job balancing context with theory, IMO.

I liked the GOF book. But what I'd really love to read about are the descriptions and (architectural) histories of complete, real software systems, especially about the design decisions and the reasons behind those decisions.

I think such information will be received with great interest - it would be like receiving a shot of condensed experience in readable form. Not exactly the same with actual experience of course, but way better than just abstract principles that leave me unconvinced.

Have you seen the Architecture of Open Source Applications[1]? I think it fits very well with what you just described. It explains not only the what, but also the why, with real examples of successful applications.

[1] http://aosabook.org/en/index.html

I remember seeing it and promptly forgetting about it. Thats precisely what I needed. Thank you.
Yup. Which is why I believe that if you really want to teach someone software design principles, you have to be prepared show them an actual, real software system; the real problem you encountered; the reason why you picked a particular solution; and the results of that choice (both pros and cons). All the details.

Given that data, its easy for a developer to extrapolate (more general) principles that may apply for their own concrete situations and problems, if any.

If you do the extrapolation of the principle yourself but hide the data that caused you to arrive to that principle, nobody will learn anything.

I have no idea why software architects do this. I guess because they're so used to abstracting all the details away in software, they start thinking it also applies to teaching/writing. It does not.

I think it's like this: Six months to two years after starting a moderately-sized code base, you start to see why these things are important. You see that they're actually saying something fairly (though not totally) concrete. The more experience you have bumping into the issues, the more concrete the advice becomes.

But I can't give that to you in something that you can read in an hour, or even a day. I might be able to give it to you in something you could read in a month (of 8-hour days reading). It's really hard to show in a one-page example.

An essay of 10-100 pages with references to the corresponding code is completely acceptable. The problem is, nobody actually does this while they're learning about it (or rather, they have other more important things to do, like the actual refactor) so there are little or no records of it.

GoF almost managed to do it, except they removed the real system context. One can almost learn something from that book :)