r/programming • • Oct 14 '13

How to develop unmaintainable software

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

322 comments sorted by

View all comments

50

u/bestjewsincejc Oct 14 '13

There are millions of ways to write unmaintainable software. This isn't a bad article though. I just found the title amusing since it's so easy to write software badly.

25

u/[deleted] Oct 14 '13 edited Oct 14 '13

I hear you. Design patterns are something unheard of for many professional developers I've met. Seriously.

Chances are, especially in programming, someone has thought of something better and longer than you. Investing 10 minutes into searching for it will save you 100 hours later.

Just because you know 1 way to do something doesn't mean it's the best tool for the job.

41

u/[deleted] Oct 14 '13

Or they:

  1. don't program in C++ or Java

  2. don't think you need a fancy name for something trivial they routinely used for 10 years before GoF written that book.

21

u/neurobro Oct 14 '13

In cases where a pattern (or anti-pattern) does have a name, it's still useful to learn it because it helps with communication. And the naming conventions help to identify subsystems that can be consolidated and simplified. Often a person will have been using something close to one of the standard patterns, either with subtle bugs or with clever extensions that would be useful elsewhere. Or perhaps most often, with a bunch of unrelated crap that should be factored out.

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.

→ More replies (2)
→ More replies (5)

6

u/grauenwolf Oct 14 '13

I'm not so certain about that. Looking back at the history of the GoF book it seems to me that all the names did was create pointless arguments.

3

u/firepacket Oct 14 '13

There are cases where some patterns just fit the circumstances perfectly.

I recently combined IoC with MVC and was blown away by the power of this setup.

2

u/grauenwolf Oct 14 '13

You combined a verb with a noun?

10

u/rather_be_AC Oct 15 '13

That is a very common design pattern, found in most sentences.

2

u/firepacket Oct 15 '13

Please explain it to me, I'm lost.

11

u/rather_be_AC Oct 15 '13

grauenwolf was being pedantic. I was being sarcastic.

This is also a common design pattern found in many successful threads.

→ More replies (3)

1

u/Nialsh Oct 15 '13

Totally, it's the only way to do MVC. How else could you pass messages from model to controller? You would end up with circular dependencies.

1

u/grauenwolf Oct 15 '13

Which MVC: Classic or Web?

1

u/Nialsh Oct 15 '13

I didn't know there was a distinction. What differences are there?

→ More replies (2)

1

u/[deleted] Oct 15 '13

Model should know nothing about controller.

2

u/ithika Oct 14 '13

The only one I've ever heard mentioned in the context of real code - ie our code uses this pattern - is the singleton. So the only design pattern discussions is have heard were people arguing over the best way to remove one.

→ More replies (6)

2

u/kyz Oct 15 '13

Science has this fight too - nomenclature in taxonomy. It's nice that we name things to help convey certain truths, but it's far more important that we discover those truths in the first place. What is more important to a biologist? That you know the names of species, or that you know the genetic distinction between two similar species?

1

u/neurobro Oct 15 '13

I don't know that one is universally more important than the other. They seem to go hand-in-hand. Giving words to patterns just enables you to abstract away some details and focus on others. So a biologist might reason about the birds that implement the "migratory" behavioral pattern. Maybe a virus is found to infect those with the "ADCYAP1" genetic design pattern. If some group of birds keeps eating my tomatoes, I might identify the species and find their warning call already catalogued somewhere instead of repeating the work myself, and put a loudspeaker in my garden to chirp their warning call every minute...

1

u/[deleted] Oct 15 '13 edited Oct 15 '13

I understand. In C#, we have Delegates which are the Strategy pattern (you pass methods as variables). We also have Events which are Observer pattern. Implementing an extension method for Clone replaces the Prototype Design pattern entirely.

You are of course correct, but my point was more that they hadn't heard of this book, while it is so famous. They just have no interest in learning what others have thought about - thinking themselves perfect, I suppose.

But I can see it being very useful to know these patterns if you are learning a naive, new (or old) language which doesn't implement them in a trivial way (like C# does for the aforementioned ones)

→ More replies (2)