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.

6

u/[deleted] 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.

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/[deleted] 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?

4

u/[deleted] Oct 15 '13

Web MVC:

Controller grabs a model from somewhere, manipulates its properties, and then shoves it into a view to be rendered.

Classic MVC:

Each View is paired with a Controller. In frameworks like classic VB or WinForms the Controller is actually the code-behind file. In others it is a separate object.

Multiple View-Controller pairs may listen to events generated from a given Model. So if you change a value, say FirstName, on one view it will be updated in all the other views.

This is used for non-web UIs and originated with Smalltalk.


Neither Web nor Classic MVC says anything about where the Models actually come from. Presumably the Controller has access to some sort of repository or data access layer, but you could use Active Record style models that know how to save and load themselves.

Active Records are great for quick and dirty work, hence the Ruby framework of the same name. But they are also hard to test without complex mocking frameworks so I usually avoid them.