Hi !
Featured games (90)
games approved by the League of Dukes
Games in Showcase (710)
Games in Android Showcase (212)
games submitted by our members
Games in WIP (784)
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 1603 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 Devvie

« 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":

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":  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 Devvie

« 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 (  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:

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

theagentd (105 views)
2017-02-18 13:42:33

theagentd (109 views)
2017-02-18 13:35:16

h.pernpeintner (1274 views)
2017-01-24 22:39:11

h.pernpeintner (1262 views)
2017-01-24 22:38:32

Galdo (1822 views)
2017-01-12 13:44:09

Archive (1926 views)
2017-01-02 05:31:41

0AndrewShepherd0 (2464 views)
2016-12-16 03:58:39

0AndrewShepherd0 (2301 views)
2016-12-15 21:50:57

Lunch (2380 views)
2016-12-06 16:01:40

ral0r2 (2156 views)
2016-11-23 16:08:26
List of Learning Resources
by elect
2016-09-09 09:47:55

List of Learning Resources
by elect
2016-09-08 09:47:20

List of Learning Resources
by elect
2016-09-08 09:46:51

List of Learning Resources
by elect
2016-09-08 09:46:27

List of Learning Resources
by elect
2016-09-08 09:45:41

List of Learning Resources
by elect
2016-09-08 08:39:20

List of Learning Resources
by elect
2016-09-08 08:38:19

Rendering resources
by Roquen
2016-08-08 05:55:21 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‑
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!