Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (499)
Games in Android Showcase (118)
games submitted by our members
Games in WIP (567)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Useful Design Patterns for Games  (Read 1213 times)
0 Members and 1 Guest are viewing this topic.
Offline GDX

Senior Newbie





« Posted 2007-10-26 10:36:57 »

Would anyone care to share which design patterns they found useful in game development and what problem those patterns solved in their games?

For example, the Template Method design pattern could be useful for a reusable game loop template because game loops are so similar between games.

Offline purpleguitar

Junior Member





« Reply #1 - Posted 2007-10-26 12:04:09 »

If you have access to the ACM Digital Library (e.g. through a university library), then you should read this paper, "Computer Games as Motivation for Design Patterns":
http://portal.acm.org/citation.cfm?id=1227391

It's one of the best papers on the topic, if I do say so myself. Smiley  If you cannot get the paper through the DL, contact me and maybe I can help.

You happen to mention Template Method in your post.  This is one pattern that I recommend to completely avoid.  Delegation is almost always preferable to inheritance.  My recommendation regarding the game loop is to make a "Game" interface with the update and render methods in it, and then have your main loop call update and render through that interface.  To use the template method introduces very strong coupling between the superclass and subclass.  It also introduces problems like Fragile Base Class.  Another great article to read is "Why extends is evil": http://www.javaworld.com/javaworld/jw-08-2003/jw-0801-toolbox.html.  Holub's writings are excellent for getting a better understanding of OOP and patterns.
Offline GDX

Senior Newbie





« Reply #2 - Posted 2007-10-27 07:14:26 »

Thanks for your responses.

purpleguitar, I found that javaworld article very interesting, even came with examples.  Smiley  I'm going to make some adjustments to my code to reflect what I've learned. I don't have access to the paper you mentioned and so no joy there.

JonathanC, I'm trying to learn more about game implementations and design patterns at the same time. For me, it's sometimes difficult to realize the benefits of a design pattern from dry descriptions of the design patterns themselves, as you might find in some books.  I was also hoping that I could narrow my focus for which patterns to better study. I understand what you are saying about not trying to force patterns into a game, but I think there must be a common set of design patterns that are naturals for the various parts of common game types.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline purpleguitar

Junior Member





« Reply #3 - Posted 2007-10-27 12:56:15 »

JonathanC makes a good point that sometimes the best way to learn is to get your hands dirty.  However, I believe that one of the advantages of design patterns is that they represent best practices, so that you don't have to recreate the same mistakes that the rest of us have in the past.  If you want to gain a deep understanding of patterns and how they are really used to build well-designed software, I highly recommend "Holub on Patterns: Learning Design Patterns by Looking at Code", by Allen Holub (APress, 2004).  Holub also wrote the article to which I linked earlier.  The majority of the book comprises two case studies: Conway's Game of Life and an embedded SQL interpreter.  He presents the patterns in the natural context of software design, and the interaction of patters makes this a much better learning source than, say, the classic Gang of Four book (Gamma, et al.).  There's nothing in the book particular to games; if you don't know the Game of Life, it's not a game like Space Invaders is a game (http://en.wikipedia.org/wiki/Conway%27s_Game_of_Life).  However, game software is still just software, and I think the lessons presented in this book are transcended of their applications, as patterns should be.

Here's an amazon link for your convenience:  http://www.amazon.com/Holub-Patterns-Learning-Design-Looking/dp/159059388X/

Good luck!
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

Pippogeek (39 views)
2014-09-24 16:13:29

Pippogeek (30 views)
2014-09-24 16:12:22

Pippogeek (19 views)
2014-09-24 16:12:06

Grunnt (44 views)
2014-09-23 14:38:19

radar3301 (27 views)
2014-09-21 23:33:17

BurntPizza (62 views)
2014-09-21 02:42:18

BurntPizza (32 views)
2014-09-21 01:30:30

moogie (39 views)
2014-09-21 00:26:15

UprightPath (50 views)
2014-09-20 20:14:06

BurntPizza (54 views)
2014-09-19 03:14:18
List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!