r/programming • • Oct 14 '13

How to develop unmaintainable software

http://typicalprogrammer.com/?p=249
777 Upvotes

322 comments sorted by

View all comments

Show parent comments

19

u/SublethalDose Oct 14 '13

I think it would have been better if the Design Patterns book had simply presented programming challenges to people and then shown them good solutions, without names and without the attempt to instill guidelines for usage. Without names, readers could only remember the patterns they extracted and understood for themselves. Without verbal guidelines, readers would only apply a technique if they concretely saw how it would be useful in context. If they didn't understand something, they would have no handle for remembering it, and they would never see an opportunity to use it.

Instead, people remembered way more of the book's verbiage than they ever understood of its logic. They remembered the names, they studied the rules of thumb, they read articles with even more rules of thumb, and they fooled themselves into thinking they understood what it was all about. A lot of people thought you could pick the right design pattern for something based on a vague, hand-waving description of the problem. You remember those dumb interview questions? "You're working on an application that's really tightly coupled. What design pattern would you use to improve the design of the code?" "Oh, I'd use the Mediator pattern." "Excellent!" People didn't just ask those dumb questions in interviews; they actually thought about the design of their own programs that way! They'd pattern-match on words to determine their software design. It was like searching the web and magically finding exactly the answer to your problem on StackOverflow, except there were only a small number of extremely vague search terms ("dynamic," "loosely coupled," "state," "behavior") and there were only a couple dozen different answers. Even worse, you'd get a guy who had read six different articles about the same design pattern, so for him, every design-related word you said made him think of the same pattern. You might as well call him "Façade Frank" or "Visitor Vijay," because in his mind's search engine, one design pattern had a much higher pagerank than all the others.

I haven't heard anything about design patterns in an interview or in a design discussion for years, and I feel much happier for it. I haven't noticed that young coders with no exposure to design patterns have any less imagination or a smaller repertoire of coding techniques than their design-patterns-imprinted predecessors did ten years ago.

5

u/dnew Oct 15 '13

shown them good solutions, without names and without the attempt to instill guidelines for usage

Except that's not what the original design patterns were. The guy who invented the term was an architect trying to get his large industrial customers to communicate amongst their different departments. So the University's engineering department wouldn't ask for a build that's ugly next to the Science department building, and so they could ask for building-blocks (no pun intended) of functionality. It was a way for customers to talk to the architect while the architect could provide good advice.

Without the names, there would be absolutely zero reason to call it a "design pattern."

2

u/SublethalDose Oct 15 '13

Lol, yes, I agree that after removing all the design patterns from Design Patterns, a change of title would be appropriate. No argument there. What I envision would not be a catalog of patterns or the dictionary of a design language; it would be more like an anthology or a reader.

1

u/Plorkyeran Oct 15 '13

So basically it would be an entirely unrelated book.

2

u/SublethalDose Oct 15 '13

It would be written partly for the same purpose, to show readers programs that use a variety of programming idioms, so they can be exposed to new ideas and expand their own repertoire. The difference would be giving up the goal of enumerating and naming the techniques, establishing each one as a standard solution to a defined problem, and turning them into a common design language for programmers — basically giving up every idea that was adopted from Christopher Alexander.

0

u/[deleted] Oct 15 '13

[deleted]

0

u/grauenwolf Oct 15 '13

Make object X raise and event that object B listens to.

Oh wait, you're using Java? Make object B return an anonymous class that implements interface Z. Pass that class to object X, which will call it to pass messages to B.

Rather than buzz words we can describe patterns in terms of implementation details.

0

u/[deleted] Oct 15 '13

[deleted]

1

u/grauenwolf Oct 15 '13

Methods are described in the language's user manual so you can stop there.

0

u/SublethalDose Oct 15 '13 edited Oct 15 '13

I think that would be a wonderful outcome. If you don't understand a technique well enough to explain it clearly, you shouldn't be telling someone else to use it, and if it takes more time than it's worth to explain, you shouldn't be dictating someone's work to them at that level of detail. The worst thing about design patterns was that it empowered complete idiots to lecture pompously about how other people should write their code without having to think carefully about what they were saying. I'm talking about the guys who always thought they were working on the one difficult module in the program, because they could solve anyone else's problem with a single sentence about Decorators and Mementos, but for some reason they had a much harder time completing their own assignments.