Design Patterns

Started by
17 comments, last by PKLoki 16 years, 11 months ago
Quote:Original post by OrangyTang
Quote:Original post by argonaut
However, as my professor thrusts these ideas down my throat, I realized that I've gotten by just fine without many of the patterns presented. Which patterns are most relevant to game design? Which patterns do you like/dislike?

If you're getting on fine without patterns, chances are you're:
1. Writing very small programs.
2. Writing bad code.
3. Using some less formal variant of patterns already without realising it.


4. Using a programming language where the issue that the design pattern is intended to work around simply doesn't exist. [smile]
Advertisement
It's definitely worthwhile learning about and really understanding design patterns. Even if you don't use them all the time and prefer to cook up your own solutions to the problems they solve, they will at very least help you avoid reinventing the wheel.

Design patterns also help you better explain your code to other people and make your code more readable. Instead of going on at length about a solution to a problem you invented, you can simply inform the person you are talking to that you used a mediator pattern. As you might imagine, this can save a lot of time in the long run.
Quote:Original post by Zahlman
Quote:Original post by OrangyTang
Quote:Original post by argonaut
However, as my professor thrusts these ideas down my throat, I realized that I've gotten by just fine without many of the patterns presented. Which patterns are most relevant to game design? Which patterns do you like/dislike?

If you're getting on fine without patterns, chances are you're:
1. Writing very small programs.
2. Writing bad code.
3. Using some less formal variant of patterns already without realising it.

4. Using a programming language where the issue that the design pattern is intended to work around simply doesn't exist. [smile]

"The design pattern"? OrangyTang wasn't talking about a particular pattern. Whilst obviously there are certain patterns which aren't needed in certain languages -- we all know Visitor isn't "needed"* in languages with multiple dynamic dispatch -- not all patterns are a workaround for language failings. For example, Façade isn't a workaround for language failings.

* Of course, in a certain sense it's never "needed" in a language without it. You can always switch on type. The question isn't "can it only be done using Visitor?" but "does using Visitor lead to better code?". As compared to switching on type, it almost always does. Even in languages with multiple dynamic dispatch, it is sometimes desirable to use Visitor.

Additionally, although there are languages where many of the GoF design patterns aren't needed or aren't applicable -- Memento, for example, just plain doesn't make sense in Haskell -- those languages have their own design patterns which in turn don't apply to Java/C++/C#.
You really need to read the first chapter of the GoF book. It explains the motivations behind design patterns and studying them, rather than just shoving them down your throat.
SlimDX | Ventspace Blog | Twitter | Diverse teams make better games. I am currently hiring capable C++ engine developers in Baltimore, MD.
I'm going to have to agree with OrangeTang. GoF was perhaps one of the only books I've read where the informational content had obvious practical application. I'd used most of them to one degree or another already. Now they just had names and a better more formal definition.
Quote:Original post by OrangyTang
IMHO if you start thinking "where can I put pattern X in my code" you'll get overengineered and generally bad results.


QFT

I think to start appreciating patterns, you need to be beyond the "n00b" stage, just because you'll be reading up on some pattern, and you'll think back to cases where that's exactly what would have been elegant (or, where that's exactly what you did, without realizing it was a documented pattern).
Thanks all for the insight! I can't wait to get my hands on the book finally (ordered it last week).

So far, the most fun I've had learning about design patterns was when I realized that I was already using some of them. That made me realize I might actually be kinda good at this programming thing :)

Don't worry ... after the coffee kicked in I realized I'm still a n00b.
~Argonaut________________________________Why "~Argonaut"? It's all just a mathematical expression denoting a close approximation of "Argonaut", which is irrational and can't be precisely defined.
Just want to further rate-up this book. I just got my copy last Friday, and haven't been able to put it down. I'm not a n00b as far as C++ goes, 5+ years experience, but not in game dev terms. I just wish I'd bought it years ago, as I'm learning a lot from it. There are so many 'eureka' moments, both for things I've known for years but never in a structured way, and completely new revelations that I just know will improve my development starting right now.

Visit http://www.mugsgames.com

Stroids, a retro style mini-game for Windows PC. http://barryskellern.itch.io/stroids

Mugs Games on Twitter: [twitter]MugsGames[/twitter] and Facebook: www.facebook.com/mugsgames

Me on Twitter [twitter]BarrySkellern[/twitter]

This topic is closed to new replies.

Advertisement