locked
Patterns are they a help or a hindrance? RRS feed

  • Question

  • I should start by saying that I have a love hate relationship with patterns so I'm interested to see what other peoples views are.

    Here are my pro's and con's...

    What's good?
    A common label to talk about...a pattern (see what's bad)
    A way of publishing a good technique so others may use it
    A way of creating code via automated guidance that conforms to a consistant and agreed path

    What's bad?
    What is a pattern? The term is overused and can be used to encapuslate anything from an algorithm, a coding style, an interview technique, etc, etc. Where does the term come from? A knitting pattern is a specific set of instructions of how to create an item, but a software pattern is, typically, an overview of how you might approach something.

    Ok so the above are things that just irrate me, but now for some serious issues;
    Reuse and guidance via patterns can be dangerous. First off I believe they restrict thinking, e.g. when I cook something I get a recipe book and slavishly following the instructions in the (vein) hope of recreating the dish. Now I'm a pretty poor cook so this is what's available to me. However, if called myself a chief you'd expect me to be able to consider some incredients and transform them into a great dish. I.e. the best chiefs and developers create the best dishes and software by being creative.

    Guidance can also be bad, for example consider a guidance tool allows you to create code that implments the singleton pattern. So I create my...Location singleton class. Great it's created using the previously agreed code. I then create a Network name singleton, an Mapper singleton, etc, etc. But wait a min' shouldn't I have created a single singleton manager class and derive from that?

    So there it is, I think patterns are good but that doesn't stop me cringing every time someone says the word, IMO they are not a, "no brainer".

    Sunday, April 27, 2008 10:33 AM

Answers

  • Here he goes again!!  Another one of those questions!

     

    Are patterns good?  Absolutely they are.  If used correctly.

     

    Imagine being a building architect instead, and how you'd go on if they didn't use patterns.  I wouldn't much want to live in one of those.

     

    The idea of being creative, whilst a good idea, is often an advanced level beyond understanding patterns, as in the example of a cook, you try what you know works (a pattern)  A cook you or I might try to do something funky, but probably wouldn't be well received in a gourmet kitchen, as we don't understand the subtleties of the cooks' pattern.

     

    To blindly follow a pattern without refactoring the design for example, or considering different ways to do things is not being an architect, and I can't imagine any architect worth their salt would ever do that.  I certainly would be looking at the problem domain, and find the most fitting path through it. 

     

    The thing is that a pattern is rarely used in isolation, thereby making it unlikely to be a no brainer, or an easy thing necessarily to find.  Often there are a number of patterns that might be used to implement a particular feature, which one would you use.  Certainly you'd have to use your brain to work that one out.

     

    Picking the wrong design pattern, and then trying to make it work is a really bad thing to do, but that's down to an incorrect choice, and thus does not detract from the fact that they're still useful when used properly.  Lack of experience or knowledge of which pattern to pick is exactly that, and nothing to do with how useful a pattern might be.

     

    My view of design patterns is that they are not always fitting, and are often only a starting point, not the end point.  Sometimes they can be used directly and with little in the way of alteration.

     

    I do think that patterns are overused, but only because people who are learning to use them, use those instead of their brains.  When I first came across patterns, I thought of them as the ways that I normally did things, but nicely and cleanly described, with an easily understandable name.

     

    That's a start at what I think about patterns,

     

    Hope that helps to continue the dialogue,

     

    Martin Platt.

    Monday, April 28, 2008 5:50 AM
  • I think that patterns are not automated guidance and like you I think being creative is more important than following patterns blindly. However, patterns are important for communication between developers either within a team or with other developers. Once a certain algorithm or idea is used many times it must be labeled so that you can fit it into the conversation. I think using patterns as part of your vocabulary and as part of your design does not restrict thinking.

    I hate it, though, when the term "pattern" is added after an idea to communicate that it is the right way of doing things and should be repeated at every chance.
    Monday, April 28, 2008 3:15 PM
  • There's a common place when talking about patterns that says "who first knows how to use a hammer likes to see a nail at every problem she faces"

     

    -Do eggs have proteins? Yes. So eggs are good

     

    -Wait a minute, eggs are not good for cholesterol

     

    -So, do you think eggs are bad?

     

    -Well, not actually. I mean, they still have proteins but eating too many on a regular diet isn't healthy

     

    -So what's bad? Eggs or eating too many eggs?

     

    -You caught me, actually the later

     

     

     

     

    With patterns the story is the same. Patterns are remedies to common diseases. Applying the wrong remedy or taking the wrong dose is harmful

    Monday, June 2, 2008 3:41 AM

All replies

  • Here he goes again!!  Another one of those questions!

     

    Are patterns good?  Absolutely they are.  If used correctly.

     

    Imagine being a building architect instead, and how you'd go on if they didn't use patterns.  I wouldn't much want to live in one of those.

     

    The idea of being creative, whilst a good idea, is often an advanced level beyond understanding patterns, as in the example of a cook, you try what you know works (a pattern)  A cook you or I might try to do something funky, but probably wouldn't be well received in a gourmet kitchen, as we don't understand the subtleties of the cooks' pattern.

     

    To blindly follow a pattern without refactoring the design for example, or considering different ways to do things is not being an architect, and I can't imagine any architect worth their salt would ever do that.  I certainly would be looking at the problem domain, and find the most fitting path through it. 

     

    The thing is that a pattern is rarely used in isolation, thereby making it unlikely to be a no brainer, or an easy thing necessarily to find.  Often there are a number of patterns that might be used to implement a particular feature, which one would you use.  Certainly you'd have to use your brain to work that one out.

     

    Picking the wrong design pattern, and then trying to make it work is a really bad thing to do, but that's down to an incorrect choice, and thus does not detract from the fact that they're still useful when used properly.  Lack of experience or knowledge of which pattern to pick is exactly that, and nothing to do with how useful a pattern might be.

     

    My view of design patterns is that they are not always fitting, and are often only a starting point, not the end point.  Sometimes they can be used directly and with little in the way of alteration.

     

    I do think that patterns are overused, but only because people who are learning to use them, use those instead of their brains.  When I first came across patterns, I thought of them as the ways that I normally did things, but nicely and cleanly described, with an easily understandable name.

     

    That's a start at what I think about patterns,

     

    Hope that helps to continue the dialogue,

     

    Martin Platt.

    Monday, April 28, 2008 5:50 AM
  • I think that patterns are not automated guidance and like you I think being creative is more important than following patterns blindly. However, patterns are important for communication between developers either within a team or with other developers. Once a certain algorithm or idea is used many times it must be labeled so that you can fit it into the conversation. I think using patterns as part of your vocabulary and as part of your design does not restrict thinking.

    I hate it, though, when the term "pattern" is added after an idea to communicate that it is the right way of doing things and should be repeated at every chance.
    Monday, April 28, 2008 3:15 PM
  • Totally agree with the idea that a design pattern is totally misused.

     

    Worked at a company that called design patterns a particular way of presenting data in the UI, it wasn't a pattern I'd ever seen, like MVC / MVP or any such, just their own thing.  That clouds the clarity that patterns bring to the table, and ends up in the starting of such discussions as this one.

     

    I don't see a pattern as being mutually exclusive with being inventive, imaginitive or whatever.  You use a pattern if it feels and feels right, otherwise if there's a better way, you do that instead.  Withi everything justifying the compromise is the key.  Not innovation for the sake of it.

     

    Monday, April 28, 2008 11:22 PM
  • There's a common place when talking about patterns that says "who first knows how to use a hammer likes to see a nail at every problem she faces"

     

    -Do eggs have proteins? Yes. So eggs are good

     

    -Wait a minute, eggs are not good for cholesterol

     

    -So, do you think eggs are bad?

     

    -Well, not actually. I mean, they still have proteins but eating too many on a regular diet isn't healthy

     

    -So what's bad? Eggs or eating too many eggs?

     

    -You caught me, actually the later

     

     

     

     

    With patterns the story is the same. Patterns are remedies to common diseases. Applying the wrong remedy or taking the wrong dose is harmful

    Monday, June 2, 2008 3:41 AM
  • Hmm, just re-reading this post after being presented with a global architecture full of copy n pasted pattern diagrams together with the very real suspicion that there is a lack of reasoning behind the choices. I think I particularily like Diego quote;

    With patterns the story is the same. Patterns are remedies to common diseases. Applying the wrong remedy or taking the wrong dose is harmful


    http://pauliom.wordpress.com
    Monday, March 7, 2011 3:03 PM
  • I used to have a bunch of toy cars and plastic tracks when I was a kid.  Hotwheels I think they were called.

    It was pretty easy to attach the various lengths of tracks and tricks together.

    Much harder to get them to work.

    Whilst the various crashes were entertaining a number of the cars got broke.

    Eventually I realised I had to think about what I was doing and quite often the tracks didn't fit what I wanted to do.

    Monday, March 7, 2011 3:57 PM