9 Replies - 1149 Views - Last Post: 07 January 2012 - 11:35 AM

#1 Cocker081288  Icon User is offline

  • D.I.C Head

Reputation: 16
  • View blog
  • Posts: 108
  • Joined: 11-April 09

Software Design Patterns

Posted 06 January 2012 - 02:04 PM

This last year at university we have started using and looking into design patterns, from simple ones such as the "Singleton" to more complex examples such as the "Flyweight" and it got me thinking.

What is your general opinion on them and how often do you use them? What is the pattern you've found you use the most and is there a pattern you enjoy using or would like to use?

I know, it's just the question you all want on a Friday.

Is This A Good Question/Topic? 0
  • +

Replies To: Software Design Patterns

#2 111027  Icon User is offline

  • D.I.C Head

Reputation: 17
  • View blog
  • Posts: 141
  • Joined: 26-December 11

Re: Software Design Patterns

Posted 06 January 2012 - 03:14 PM

From what i've picked up working around as a volunteer, no one actually uses the patterns themselves. They're usually used as starting points in design, used to build your own patterns on top of them. My opinion was heavily influenced by the people i worked with - and learned from. They're a nice way to get a feel for software architecture, but after that, you need to adapt them to your own needs and style.

Also, they're not applicable in all situations. Namely, they'd only do you good in Object Oriented design. But say you needed to write a procedural program in C or the likes. How would you manage that if you've holding on to the patterns themselves for your entire career, instead of the ideas behind them?

Just my 2 cents, mate. Interesting topic.
Was This Post Helpful? 1
  • +
  • -

#3 wordswords  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 76
  • View blog
  • Posts: 272
  • Joined: 17-December 11

Re: Software Design Patterns

Posted 06 January 2012 - 06:33 PM

In my opinion, the appropriate use of software patterns is one of the things that distances an experienced developer from from someone that is just starting out.

'Patterns' is just a word for reusable software design ideas. The 'Gang of Four'[1] book gave us the most commonly used set of patterns, ie: Singleton, Factory etc. But you can have a Factory and a Singleton pattern, and then throw in a few specialist distributed system design patterns that you have discovered from reading a specialist journal. You only have to use them if you think they will help. Most of your code will not be a 'pattern', but it is good to include a pattern when it is appropriate. You can have patterns in functional programming also, but they won't be the same as OO patterns.

Learning when and where it is appropriate to use patterns is a software design skill, and it takes years to develop but is worth practicing. If you have read the Gang of Four or a similar book then that will also give you the vocabulary to understand other peoples' code when they use patterns. There are lots of examples of patterns being used in open source code, and if you don't understand the patterns then it becomes more difficult to understand the code.

Also it's worth reading about 'anti-patterns', which means common mistakes in design that people frequently use, and should be avoided.

[1] - http://www.amazon.co...d/dp/0201633612

This post has been edited by wordswords: 06 January 2012 - 06:36 PM

Was This Post Helpful? 1
  • +
  • -

#4 jon.kiparsky  Icon User is offline

  • Pancakes!
  • member icon


Reputation: 8037
  • View blog
  • Posts: 13,757
  • Joined: 19-March 11

Re: Software Design Patterns

Posted 06 January 2012 - 11:50 PM

Quote

In my opinion, the appropriate use of software patterns is one of the things that distances an experienced developer from from someone that is just starting out.


It's worth reading some of the literature on design patterns, even though little of it is any good. The Gang of Four book is nearly unreadable, IMO, and the names they established are almost entirely useless, in that they fail to communicate much of anything. (What does "Flyweight" mean, and what does it have to do with boxing?)
There is some wisdom encapsulated there, though it can be difficult to find. Design patterns should be treated more like idea pumps than like recipes. They're ways of describing good ideas that many people have already had, which you might have had yourself. The main problem is that it's hard to recognize the wisdom of a particular pattern until you've actually made the mistake that it addresses. Anyone can tell you that it's better to separate business logic from presentation logic, and they can explain the reasons, but you don't really know why this makes sense until you've actually made the mistakes and had to untangle a hopeless design.

For this reason, I wouldn't steer a beginning programmer to design patterns at first. Go out and make a bunch of mistakes first, then go look at solutions. Once you've made the mistakes, you can understand the underlying logic that led to this pattern, and you can actually understand how it should be implemented.
Was This Post Helpful? 1
  • +
  • -

#5 Cocker081288  Icon User is offline

  • D.I.C Head

Reputation: 16
  • View blog
  • Posts: 108
  • Joined: 11-April 09

Re: Software Design Patterns

Posted 07 January 2012 - 06:10 AM

These are all interesting points, I wondered why uni had left it till my final year to introduce patterns, I can only assume it's because they must believe we are at the level now where we can make these decisions and explain why we chose certain patterns.

I am a bit surprised however how you've all only found them of little use as they were breeched to us as the best thing since sliced bread.

It looks an interesting subject.( I have the Head First Design Patterns book I was recommended the gang of four but told this would be just as relevant for us and a lot easier to read)

When I get some spare time I may create a few bits of software that include these patterns to gain a better understanding, any recommendations on which would be the best to try?
Was This Post Helpful? 0
  • +
  • -

#6 111027  Icon User is offline

  • D.I.C Head

Reputation: 17
  • View blog
  • Posts: 141
  • Joined: 26-December 11

Re: Software Design Patterns

Posted 07 January 2012 - 06:29 AM

No such thing, mate. It depends on the problem. If you want to create a media player, for an example, then the Singleton pattern is the best. But for a card game simulator it might not do.
Was This Post Helpful? 0
  • +
  • -

#7 Cocker081288  Icon User is offline

  • D.I.C Head

Reputation: 16
  • View blog
  • Posts: 108
  • Joined: 11-April 09

Re: Software Design Patterns

Posted 07 January 2012 - 06:34 AM

Sorry, I meant as in which would be the most interesting to do as the simpleton is quick easy and quite boring.
Was This Post Helpful? 0
  • +
  • -

#8 jon.kiparsky  Icon User is offline

  • Pancakes!
  • member icon


Reputation: 8037
  • View blog
  • Posts: 13,757
  • Joined: 19-March 11

Re: Software Design Patterns

Posted 07 January 2012 - 08:50 AM

View PostCocker081288, on 07 January 2012 - 08:34 AM, said:

Sorry, I meant as in which would be the most interesting to do as the simpleton is quick easy and quite boring.


This is why I say they should wait until you've written more code.
You're asking us "which answer is best?". I don't know, what's the question.
That being said, you might as well look at Model-View-Controller. It's pretty generally useful, and not hard to understand.
Was This Post Helpful? 0
  • +
  • -

#9 111027  Icon User is offline

  • D.I.C Head

Reputation: 17
  • View blog
  • Posts: 141
  • Joined: 26-December 11

Re: Software Design Patterns

Posted 07 January 2012 - 11:17 AM

That's an interesting pattern, yes. Kudos on the suggestion.
Was This Post Helpful? 0
  • +
  • -

#10 Cocker081288  Icon User is offline

  • D.I.C Head

Reputation: 16
  • View blog
  • Posts: 108
  • Joined: 11-April 09

Re: Software Design Patterns

Posted 07 January 2012 - 11:35 AM

Thank you for all the input guys!
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1