• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:
  • Lou Hamers
  • Piet Souris
  • Frits Walraven

New Article: Evil Patterns

 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
A rootin', tootin' new article entitled "Evil Patterns", written by Paul Wheaton hisself, appears in the latest issue of the JavaRanch Journal. You kin check out that there article here. Y'all have anything to say about it? Say it right in this thread!
 
Ranch Hand
Posts: 96
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I couldn't have said it any better myself! All too often I look at the design of a software project and say to myself "Why on earth are they using this pattern here? It would be much simpler to do it this way..."

In one project, I compared the over-use of design patterns to a Knight. A knight shrouded in extreme armor may be invulnerable to swords or arrows, but what good is he if he can't move or maneuver? That's what software becomes when you load it up with unecessary patterns. It may be strong and robust, but most of the times, its overly complicated and performance degreades.

Just my thoughts
 
Bartender
Posts: 2968
6
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


I think that any pattern being used in an application could/should(/must!) be trumped by "the simplest thing that could possibly work."



Back in 2002 Scott Ambler warned in his book Agile Modeling to Apply Patterns Gently (page 62, referencing both Joshua Kerievsky's "Patterns and XP. Extreme Programming Examined"; 2001, pp.207-220 and Martin Fowler's Is Design Dead: Patterns and XP (2001)).

It's nothing new that most people are a bit overzealous with their "new" toys - though Design Patterns: Elements of Reusable Object-Oriented Software (Jan 1995!) has been around for a while - but it seems it took something like Head First Design Patterns (Oct. 2004) to make design patterns generally accessible and "really popular". Maybe now design patterns can finally become "just" yet another tool that is only applied when appropriate.
There is no need to introduce patterns pre-maturely as they can be introduced at a later point of time when the benefits are clear.
Refactoring to Patterns (Aug. 2004) Joshua Kerievsky
Working Effectively with Legacy Code (Sep. 2004) Michael Feathers
[ March 22, 2006: Message edited by: Peer Reynders ]
 
author
Posts: 288
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I was one stage over zealous too. especially when I started learning design patterns. In my view, learning a design pattern is easy, but more difficult part is to identify when and where they can be effectively applied.
 
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks, Paul, I felt like you were channelling my own thoughts there.

The only point I'd add is the 'Pattern as a weapon' ie "I know more patterns than you, so rather than using them as an aid to communication I'll deluge you till you give up and walk away". I've seen this a couple of times
 
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by David O'Meara:
Thanks, Paul, I felt like you were channelling my own thoughts there.

The only point I'd add is the 'Pattern as a weapon' ie "I know more patterns than you, so rather than using them as an aid to communication I'll deluge you till you give up and walk away". I've seen this a couple of times



Or, my favorite, Since I am talking louder, then I am right and you should use the Patterns that I want to use.

Mark
 
Ranch Hand
Posts: 178
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I tend to disagree with the prevous posters (and the article). Most of the software I've seen (which is a subset only, of course) didn't suffer from too much patterns, it was always the opposite. Really creepy code that was very difficult to maintain, especially after some changes. A well-used(!) pattern would have done wonders to the code's structure.
 
Ranch Hand
Posts: 226
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think I've seen one project that was too overloaded with patterns. I've seen far more projects that needed some patterns applied to reduce developer ramp up time. "The simplest thing that could possibly work" - I definately wouldn't go that far. Patterns aren't simple until you know them, then they allow you to make generalizations that should be true - IE this is a DAO I expect to find code here to load/save/update an object.

A newbie will tell you the simplest thing is one giant class file - like the 800 line web service I got the source to this week (inline JDBC and other web service calls).

I also tend to disagree with the "don't get suckered by some putz". Anyone can have a good idea, don't wait until "the greater minds" tell you something is a good idea if you find an idea and like it. Play with, learn it, make it better.

Just my 2 cents from "some putz"
 
Ranch Hand
Posts: 443
3
Eclipse IDE C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I used to love design patterns, but it seems to often often into an excuse for documentation ...

- Problem 1 :

The vocab bit can break down as one persons pattern is not another persons ...
I had an argument with a web developer who claimed they didn't need to document their code as is was MVC and I should therefore know that and not require any , it was actually Sun's specialisation of MVC, so I pointed this out by showing them the GoF book only to be told I was of course wrong and that book was in error ;-) "That's not a MVC"

Problem 2 :

Another instance ... some one recently claimed I hadn't followed their pattern on a project, I replied that I wasn't aware there was one, apparently I should have inferred it again used as an excuse for the omission of the simplest of comments.

Just for anyone else listening a new design pattern with out documentation is not a design pattern it's a cryptic splodge :-(

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Chris Hurst wrote:

- Problem 1 :

The vocab bit can break down as one persons pattern is not another persons ...
I had an argument with a web developer who claimed they didn't need to document their code as is was MVC and I should therefore know that and not require any , it was actually Sun's specialisation of MVC, so I pointed this out by showing them the GoF book only to be told I was of course wrong and that book was in error ;-) "That's not a MVC"



The problem with this story is that MVC is not a GoF pattern. A lot of people claim it's not a pattern at all.
 
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Mike Himstead wrote:I tend to disagree with the prevous posters (and the article). Most of the software I've seen (which is a subset only, of course) didn't suffer from too much patterns, it was always the opposite. Really creepy code that was very difficult to maintain, especially after some changes. A well-used(!) pattern would have done wonders to the code's structure.


This has also been my experience. I have seen some really bad abuse of patterns, usually in an attempt to look good to management and other less-knowledgeable developers. However, the beast I have always had to fight was the OO code that was not based upon good understanding of OO principles and lacked any use of design patterns. The mis-use of a design pattern is can often be fixed with some effort but fixing a C program written in Java is often a fight with an ugly beast.
 
Ran Pleasant
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Michael Valentino wrote:A knight shrouded in extreme armor may be invulnerable to swords or arrows, but what good is he if he can't move or maneuver?



Off topic but just for the general knowledge: A knight was not invulnerable to swords or arrows and they actually were very maneuverable. Same weight load as a modern soldier except that the load was spread over the whole body, not just the back. Movies and TV are a bad place to learn history.
 
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm glad people write articles like this. It serves as a warning to addicts like myself that too much of a good thing can kill you. I am currently in a debate with myself over the balance of design patterns vs. simple (yet ugly) solutions. For example, I HATE redundant code. I can't stand writing the same thing twice and then having to fix it twice when requirements change. Patterns help you eliminate redundancy. That's one of the reasons I became infatuated with them. But there is a cost in overhead and understandability (e.g., defining and implementing interfaces, wiring in Spring, dividing code up into smaller modules). It makes no sense to implement the Strategy pattern to save a few lines of redundant code. You more than pay for it in overhead. So I find myself constantly trying to balance the tradeoffs, wishing there was a way I could eliminate the redundancy while not having the overhead. But I don't think there is a silver bullet answer. The reality is this: life ain't always pretty, and sometimes code ain't either.
 
Sheriff
Posts: 67750
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It's called engineering.
 
Bob Lawson
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Bear - was that at me? If so, not sure how you meant it.
 
Bear Bibeault
Sheriff
Posts: 67750
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Was the not clear enough? Engineering is the art of balancing the benefits and drawbacks of any approach.
 
Bob Lawson
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Gotcha - good definition.
 
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
One of the patterns I'm sick to death of is the Template pattern. There are way too many in-house, home-grown frameworks in the Java web application space that excessively use this pattern. I mean it's so hard to follow the logic around because you keep jumping between sub-classes and super classes. Which methods do I override, and when etc... And to top it all, most of these frameworks are poorly documented, which makes it doubly hard to understand them, especially for the new guys on the team. I think there are good examples of its usage also (Spring) but they come with excellent documentation. Although, the fact that it requires heavy documentation to simply start using it should be a sign that it could be done better.

It makes me wonder what are some of the other ways of designing through which these problems can be avoided.

Just chiming in...
 
Bob Lawson
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Robin Sharma wrote:I mean it's so hard to follow the logic around because you keep jumping between sub-classes and super classes.



If you are jumping between super and sub, you may not be implementing the pattern correctly. It should always be one-directional (Don't call us, we'll call you principle), where the super contains the general algorithm and calls through abstract method for variations to that algorithm. Its the same way for the strategy pattern, just compositional instead of inheritance. Both these patterns allow implementation of Inversion of Control. So perhaps the issue is that you've seen abuses of the template method pattern.
 
Ranch Hand
Posts: 89
Eclipse IDE Tomcat Server Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i would rather think of how the future will affect my design when creating a system. Then tell my self, "Wow, i never imagined that i have a strategy pattern here!"
 
Bartender
Posts: 10780
71
Hibernate Eclipse IDE Ubuntu
  • Likes 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

All too often I look at the design of a software project and say to myself "Why on earth are they using this pattern here? It would be much simpler to do it this way..."


That strikes me as a comment on how patterns are used, rather than a condemnation of them in general.

As Einstein said (sort of) "everything should be as simple as possible; but no simpler" and, while I'm all in favour of dumb programming, Paul's article (or at least the digest I found) struck me as a rather Luddite exhortation to 'simplicity'.

Patterns are tools; nothing more, nothing less. If you don't like 'em, don't use 'em; but you'll be missing out on a lot of acquired knowledge and will probably end up re-inventing the wheel in the process.

Me, I just got a new copy of GoF about two months ago and am thoroughly enjoying re-reading it.

Winston

 
Bartender
Posts: 1464
32
Netbeans IDE C++ Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Winston Gutkowski wrote:

All too often I look at the design of a software project and say to myself "Why on earth are they using this pattern here? It would be much simpler to do it this way..."


That strikes me as a comment on how patterns are used, rather than a condemnation of them in general.


Agreed. When I was still working in shops (and this was before patterns took over the world), this phenomenon was rampant, and said rather more, I thought, about the programmers than it said about their programming. At almost every design meeting, formal or informal, at the places I've worked, the discussions rapidly devolved into debates over who could prove their idea was the best. The counter to each attempted proof, of course, was to argue that the proposed design was dumb, and showed the ignorance of its proponent. Everyone had their favorite way of doing things and, mostly, that favoritism was based on the comfort of knowing that one would never appear ignorant one's self (by ever saying anything along the lines of, "hey, your idea looks pretty good; would you teach that to me?").

When I read, "Head First Design Patterns," it was a game-changer for me. I could instantly see how my own coding had mucked up a lot of things that could be done more simply, if I were humble enough to admit there was a lot for me to learn. Heck, that's why I love coderanch.com. Mostly, if one says, "Here's what I'm doing, but I think there's a better way," people will politely offer their help. That's kind of a new experience for me, in the software world .

So, I think patterns are great, but, like everything else, only when used properly. They've certainly made my life simpler, but then, I pretty much only ever have to grapple with my own code, so the option to blame that idiot in the next cube over for a method or a class that I don't like is kind of absent here. I might feel differently if I were still in a team setting, but, again, I have to wonder if that would be due to the team members' behavior, rather than the fact that patterns are part of a programmer's toolbox.
 
Climb the rope! CLIMB THE ROPE! You too tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic