Reply to post: Re: Java's only impact.

Celebrating 20 years of juicy Java. Just don’t mention Android

JLV

Re: Java's only impact.

Upvoted (what's with the OP attributing Pattern necessity to the JVM???), but let's not jump to conclusions too quickly.

Language does matter. If you can, say return function pointers, then you may find whole categories of problems for which Strategy is overkill. Factories? Great, when needed.

Design Patterns holds a special place in my esteem. Reading GoF's book was the first time I truly got how OOP was supposed to work. Most of the other books I had read either started getting lost in deep OO theory without clear rationale for their approach or else immediately fixated on explaining inheritance one more time. First book that clearly got me to think in terms of composition instead.

But, and I believe it might even have been said in that book, do not implement a Pattern lightly. Well-done, it solves a problem. Done willy-nilly, just because everything looks like a nail complicated to your mighty hammer Patterns, it creates horribly messy and convoluted code.

Did some debugging on a failing enterprise SOA-style expense processing system. 1 expense report, with 1 expense line in it => 20 MB trace, 500+ function calls, dozens upon dozens of objects being instantiated. And many, many, Patterns of all stripes, factories foremost. Impossible to track what was going on. (I never did figure it out but ending up diff-ing a successful run log with a failed run log and caught the issue - failing external API call - that way instead).

It wasn't in Java, but OMG did it have Enterprise Java Programmer Here written all over it!

Code composition, which is a lot of what Patterns are about, is an extremely powerful technique. But there is a tension between very clever dynamic code and easily readable code. Stupid fixed procedural code may be dumb, but it can also be easier to read.

Read this guy's "hacker code" vs. "clever code" for example. Wasn't meant to be ironic. If you need the complexity, fine. If you don't, please think twice before reaching for that hammer. Maybe think it through with a unit test instead.

http://csis.pace.edu/~bergin/patterns/ppoop.html

Personally, my main beef with Java is not so much the language itself, as the perception that its culture is not one that values simplicity.

POST COMMENT House rules

Not a member of The Register? Create a new account here.

  • Enter your comment

  • Add an icon

Anonymous cowards cannot choose their icon