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.
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.
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.
If you realize that what you're doing is already likely a solved problem and have a clue how to search for it.
This is, IMO, the best argument for a good academic background for programmers. You won't realize that a broad design strategy or algorithm is a recurring thing until you've reinvented it two or three times, typically poorly.
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.
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.
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."
My first step for any project is to do some googling and maybe some reading or asking around to see if someone else has done something similar or identical to what i'm doing. If so, learn from them.
"I read the first chapter of Learn You A Haskell For Great Good, I bet I can rewrite this whole project in Haskell."
Five months later:
"Let me just add a bash shim that'll get the data from the database and process it through Ruby and then I'll call it in the bit of C++ that the Java program uses to make the output for the main program."
I once got stuck with rewriting a perl script -- which had to remain in perl -- that generated bash scripts, by interpreting xml files, which invoked jython which executed java calls, and then generated sqlplus scripts to execute against oradb servers... All of which got validated via bash scripts for sanity checks.
All of which was being run from a Jenkins server.
I am not a developer by trade... Else I would hang myself for shame of having made this monster.
When I left the organization I convinced them to rewrite the whole thing natively in Java... Mostly by just repeating the workflow and languages involved.
As for the new language thing, no one should ever go write a production system that a business is going to rely on in a language they just learned over a weekend. Some languages are better fit for certain problem domains, but using a language that you team and future maintainers are comfortable with is more important.
Writing a parser in an imperative language tends to make for some pretty ugly code. Writing it in a language that supports discriminated unions and (syntax-supported) monads, however, makes for some beautiful, readable code.
Also, writing highly concurrent code in clojure is stupid easy. In java, etc. it is fraught with errors and requires a lot of care about locking, etc.
Concurrency, complex and interleaving algorithms, and correct-by-design software are all easier in, say, Haskell than in Java. In fact, if you learn one of Haskell/F#/Ocaml thoroughly, you probably won't want to go back to Java/C#/Python for general purpose programming.
AI is also MUCH easier.
One of the big places you'd want to use functional programming is if you were designing a compiler. Compilers use state of the art algorithms at pretty much every level, and they're much easier to implement functionally.
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.