Skip to main content
gamedev.net
🔒 Locked

OOP Design Patterns

Started by caseyd Apr 13, 2005 at 11:27 PM 5 replies 1.7k views
Original Post
caseyd
caseyd
I've been programming with c/c++ for a while now, but have recently just started programming again after an extended break. I am really focusing on getting a better understanding of OOP. Most of the games I've done using oop have all been of the singleton nature. I was wondering what design patterns are used more than others in game programming?
Cygon
Cygon
They are probably along the lines of these:

Double Dispatch, Visitor (collision detection),
Factory, Prototype (savegames, spawning),
Facade, Adapter (wrappers),
Chain of Responsibility (file recognition),
Flyweight (particles)

You'll surely find more, if not the full range of the GoF book, in a professional game engine written using OOP.

-Markus-
Professional C++ and .NET developer trying to break into indie game development.
Follow my progress: http://blog.nuclex-games.com/ or Twitter - Topics: Ogre3D, Blender, game architecture tips & code snippets.
Cygon
Cygon
Sure, you could do that also. I was just giving examples where I saw those patterns would be useful.

The chor pattern would be useful if you decided to go and let each FileDecoder or whatever objects you've got open the file and check whether the file's header is a format it knows.

-Markus-
Professional C++ and .NET developer trying to break into indie game development.
Follow my progress: http://blog.nuclex-games.com/ or Twitter - Topics: Ogre3D, Blender, game architecture tips & code snippets.
Ilankt
Ilankt
Quick question, is Singletion good for the graphics wrapper?
How appropriate, you fight like a cow!
Seriema
Seriema
Singleton is the most over- and missused pattern of all. You can use it for almost anything and it "makes things so easy" to code, but it makes it a hell to maintain and expand - or for outsiders to understand the flow of the program.

Just don't do it...
[ ThumbView: Adds thumbnail support for DDS, PCX, TGA and 16 other imagetypes for Windows XP Explorer. ] [ Chocolate peanuts: Brazilian recipe for home made c
Zahlman
Zahlman
Agreed. In C++, the only good typical reason for bothering with one is to solve problems with static order of initialization. In some other OO languages (including Java), such problems do not exist (unless you have a circular dependency, in which case you're screwed regardless).

Consider static interfaces or various forms of Monostate, and proper use of namespaces to restrict scope.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.