Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical

Re^2: Programming patterns

by dsheroh (Prior)
on Jun 28, 2012 at 09:27 UTC ( #978868=note: print w/replies, xml ) Need Help??

in reply to Re: Programming patterns
in thread Programming patterns

It's really interesting to hear the opinion that following patterns religiously can also lead to "bad" code.
The thing to remember about patterns is that they're meant to be descriptive (a way of communicating what you're doing to other programmers) rather than prescriptive (a way of telling you what you should do). Bad code frequently results when you take a list of patterns and decide to use them purely because they've been blessed as Patterns(TM) rather than analyzing your problem, looking to see the most appropriate way to solve it, and then using patterns to express that solution.

There's also the side issue that patterns are generally ways of filling gaps in the language that you're using (Perl has no patterns for finding text which has certain characteristics within a string because the language's built-in regex support is better than anything you're likely to write in your application code), so problems also arise from inappropriately applying one language's patterns in another language which has a better way of solving the problem at hand, but that seems to be a less common cause of pattern-derived bad code.

Replies are listed 'Best First'.
Re^3: Programming patterns
by jdporter (Canon) on Jun 28, 2012 at 13:54 UTC

    Absolutely right on both counts, dsheroh. Well said.

    However, I would rephrase "Perl has no patterns for..." as "Perl programmers don't need patterns for...", since, generally, patterns don't exist within a programming language. (I mean, obviously there are patterns in the design of a language, but that's a different animal.) Also, I think you should have chosen a different example than "finding text ... within a string", since, in the context of that kind of problem, the term "pattern" has another meaning, so the description of your example could be (certainly was to me at first) confusing.

    I reckon we are the only monastery ever to have a dungeon stuffed with 16,000 zombies.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://978868]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (6)
As of 2018-01-23 22:29 GMT
Find Nodes?
    Voting Booth?
    How did you see in the new year?

    Results (254 votes). Check out past polls.