Jump to content

  • Log In with Google      Sign In   
  • Create Account

Design patterns and game development


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
9 replies to this topic

#1 Puyover   Members   -  Reputation: 187

Like
0Likes
Like

Posted 02 March 2013 - 03:22 PM

Hi there,

 

I'm currently returning to game development from my traditional software development, but years ago when I started with C and SDL I didn't care about design patterns at all, so now I found myself surrounded with their chaos and can't simply code without standing with one of them.

 

I don't understand which one fits better into game dev (MVC? Components? ... ), and indeed, I don't know many of them however.

 

So my question is, where to start in design patterns? I'm studying the library SFML with C++ right now, which is a language I had forgotten (And I hated) but industry right now almost force you to know C++, and I was very lazy with Java, so I need that change.

 

Thanks in advance.



Sponsor:

#2 skullfire   Members   -  Reputation: 355

Like
5Likes
Like

Posted 02 March 2013 - 04:16 PM

Hi Puyover,

 

In my opinion, componentization has been a very good architecture design decision for games as it provides a lot of reusability as well as elegance. In games, try to prefer components over inheritance. I'll leave this references here:

 

http://cowboyprogramming.com/2007/01/05/evolve-your-heirachy/

http://www.richardlord.net/blog/what-is-an-entity-framework

http://www.richardlord.net/blog/why-use-an-entity-framework

 

Hope this helps!



#3 Puyover   Members   -  Reputation: 187

Like
0Likes
Like

Posted 02 March 2013 - 04:26 PM

Hi Puyover,

 

In my opinion, componentization has been a very good architecture design decision for games as it provides a lot of reusability as well as elegance. In games, try to prefer components over inheritance. I'll leave this references here:

 

http://cowboyprogramming.com/2007/01/05/evolve-your-heirachy/

http://www.richardlord.net/blog/what-is-an-entity-framework

http://www.richardlord.net/blog/why-use-an-entity-framework

 

Hope this helps!

Thank you skullfire, nice to know there is a pattern at least which is well established into game development tongue.png

I will give that articles a read.


Edited by Puyover, 02 March 2013 - 04:27 PM.


#4 frob   Moderators   -  Reputation: 21131

Like
7Likes
Like

Posted 02 March 2013 - 07:29 PM

Hi there,
years ago when I started with C and SDL I didn't care about design patterns at all, so now I found myself surrounded with their chaos and can't simply code without standing with one of them.
 ...
So my question is, where to start in design patterns?

Design patterns are simply patterns that are frequently observed in good (or bad) software.

People say "I did this thing lots of times", and name it, and talk about it publicly, and then it gets called a pattern.

You can read books or web pages on design patterns all you want, they will help teach you things you can do, and things that are not recommended.

The thing about the patterns is that they are useful in discussing what is going on.

Patterns are not some magical thing that you must use; they are just designs that people noticed were frequently found in code.

There are various wikis filled up with thousands of design patterns. If you don't have a design pattern that fits your goals, write a design of your own.
Check out my personal indie blog at bryanwagstaff.com.

#5 flodihn   Members   -  Reputation: 243

Like
2Likes
Like

Posted 03 March 2013 - 07:21 AM

If you are building your code by trying to put together a few design patterns you are doing it wrong.

 

You should reason about your application, design it to fit your goals. If some of your design turns out to be a exact or very similar version of an existing design pattern, you name that code after the design pattern to make it easier to recognize this familiar pattern.

 

I have encountered a few people out there (very smart people) that have done some coding and when reading it, I discover a design pattern hidden by custom names. The very idea of design patterns is that they other developers should recognize them and thus having design pattern, but not organizing your code after it misses the very idea.

 

For example, if you are rolling a MVC architecture, split the application into one model, view and controller layer named just that. Don't create a bunch of files named x, y, z and make them behave as a design pattern. Of course this applies to class names/functions etc.

 

So my suggestion is to first think about the design from a bird's eye perspective, figure out what layers you want, often de-coupling / few dependencies is a goal for a well designed application.

Once you have that down, you can start to look if your solution would be or close to be a design pattern and make sure it is clear in your code.

 

For example, you might decide that you want 3 tier system that decouples the rendering, the logic and the data (http://en.wikipedia.org/wiki/Multitier_architecture).

 

For the rendering you decide a data-oriented component based system would fit best, while you roll a chain of command structure to handle the logic in the logic layer.

Also looking into the model you might decide to make it a more standard OO design of those since those are not run in an update loop and cause cache misses.

 

For communication between those layers you might find that the observer pattern is close to the design of the logic->data layer, while producer/consumer is more close to the rendering->logic layer.

 

This is pretty hard to get right from the start, it requires a lot of experience, which you only get by doing it. Good luck :)



#6 Lightness1024   Members   -  Reputation: 736

Like
2Likes
Like

Posted 03 March 2013 - 08:54 AM

Hi there,
years ago when I started with C and SDL I didn't care about design patterns at all, so now I found myself surrounded with their chaos and can't simply code without standing with one of them.
 ...
So my question is, where to start in design patterns?

Design patterns are simply patterns that are frequently observed in good (or bad) software.

People say "I did this thing lots of times", and name it, and talk about it publicly, and then it gets called a pattern.

You can read books or web pages on design patterns all you want, they will help teach you things you can do, and things that are not recommended.

The thing about the patterns is that they are useful in discussing what is going on.

Patterns are not some magical thing that you must use; they are just designs that people noticed were frequently found in code.

There are various wikis filled up with thousands of design patterns. If you don't have a design pattern that fits your goals, write a design of your own.

Yeah but naming something a pattern also allows a community to refine it to its purest and most robust form. like boost did with smart pointers for example. or iterators, optional, variants, destruction closures and wtf you name it...

 

Entities/components, seriously, this is not a pattern. a pattern is a factory, or a visitor. it is a part of the code. (a very small part)

entity/component however, is the paradigm you choose to code with. so instead of functional, or object oriented, or procedural, you will choose entity/component.

It is much higher over patterns for me, it is a paradigm. It encompasses your whole program, and you code into it, not the other way around.

 

though, same property, naming it will allow community to refine it.

 

I see one big issue, that was covered by some of the 3 links : adoption by peers in the same company. hem; the guy of tony hawks had an ONLY 3 year old code base, and very very understanding coworkers to finally go along with the adoption. Frankly, in my company, the chance of adoption is zero, yeah, the Kelvin absolute cold 0.



#7 flodihn   Members   -  Reputation: 243

Like
0Likes
Like

Posted 03 March 2013 - 12:02 PM

I find that wikipedia is a really good resource for reading about existing design patterns:

http://en.wikipedia.org/wiki/Software_design_pattern



#8 Uberwulu   Members   -  Reputation: 150

Like
0Likes
Like

Posted 03 March 2013 - 09:48 PM

Design patterns are not chaos.  They clean up the chaos.

 

As far as your question, the series on Pattern Oriented Software Architecture (5 volumes), Design Patterns, and Game Engine Architecture are good resources.



#9 larspensjo   Members   -  Reputation: 1538

Like
0Likes
Like

Posted 04 March 2013 - 06:11 AM

Entities/components, seriously, this is not a pattern. a pattern is a factory, or a visitor.

 

I disagree. Entity-Component-System is a behavioral pattern that can be seen as an extension of the Strategy pattern, which is one of the early design patterns (found in "Design patterns").


Current project: Ephenation.
Sharing OpenGL experiences: http://ephenationopengl.blogspot.com/

#10 Lightness1024   Members   -  Reputation: 736

Like
0Likes
Like

Posted 04 March 2013 - 08:57 AM

Well. after all, I cannot deny that this is a design. On another hand, I can't deny that this has been seen and documented many times either, so it is a pattern. Therefore, in the end, it is a "design pattern" when you put the two words together.

However, I disagree with the comparison with Strategy, or maybe a reversed strategy then. Because strategy uses modular code. ECS uses modular data. So somewhat its the reverse. And I repeat why I don't like the comparison with any design pattern, because existing patterns until now don't concern the whole code base. ECS is one of a kind.

 

ps: Isn't it off topic ?






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS