Jump to content
  • Advertisement
Sign in to follow this  
ManaStone

What type of design patterns do you use?

This topic is 4815 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

What type of design patterns do you generally use when making a game? I don’t have much experience making games, but one style I like is where you make one application class to handle the basic application shell and then you derive a new class of that to define your frame function and application data. My instructor says that isn’t a very good way to design a system. He said that that type of method was used to develop MFC and because of that, it was very hard to make improvements of later versions of MFC without mucking it all up.

Share this post


Link to post
Share on other sites
Advertisement
The only one i find useful in the stuff i write is the singleton, well i probably use others but i dont recognise the code patterns.

ace

Share this post


Link to post
Share on other sites
For an OO(-ish) game/game engines you'll find that you will use virtually all or most of the GOF patterns working together, even without realizing it. This is especially the case and evident for programming languages that lack certain Post-OO features and higher level constructs from other paradigms natively hence requiring to implement a pattern in a programming language, usually as reusable generic library/component.

It's not surprising to see a game/game engine even use them all, some you will definitely find are:



  • Composite - in many places, GUIs, Game GUIs, scene graphs etc


  • Visitor - Separation of Data from Their Operations, usually used with/on Composites to abstract and centralize imp specific operations. It is also used to get/simulate dynamic double dispatch in languages that only support single dynamic dispatching (like java, c++).


  • Observer - loosely coupled internal communication between entities/objects, can be used for GUI/Game event handling but not limited to event handling only.


  • Factory Method/Object factories - almost always find them in OO solutions, it can be considered compulsory for statically typed languages using polymorphic types.


  • Command - Game GUIs etc


  • Iterator - without thinking about it everywhere, nothing specific


  • Strategy - again lots of places nothing specific



I could probably go on, you'll definitely find more than 1 being used without realizing it. Also note that as these are patterns usually each language can implement them in a better ways using idioms specific to that language for e.g. .NET delegates can be considered an automated imp of the observer pattern. In c++ some standard library containers use strategy pattern but using templates as a type parameter for efficiency and type safety etc.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!