Design experimentation. What do you guys think?

I’m spending some of my time (while not playing games) experimenting with different design strategies.

I’ve come up with this design:
http://members.optusnet.com.au/ksaho/designs/Mechanics.java

I realise that I should synchronise the 2 arraylists as well as update the sprite’s coords in the GameInterface, but for now I’m just trying to get a good general design.

What I usually did with my previous design was create an object, hold it’s own rendering information as well as data.
That of course didn’t look all that flash, however I’m hoping you guys would criticise my design.

I’ve spent 2 years messing around with different designs. I could never come up with a perfect design. I’ve come to believe the idea of a perfect design is fallacy and I really can’t find a design that works everywhere.
Regardless of whether I’m creating a game/business/internet based apps.
I just cannot do it.
I try my best to generalise my designs to work everywhere. Unfortunately it just can’t happen, especially when you move to web apps.

Anyone know of a near perfect design whether it be in OOP, AspectJ, procedural, etc…?

The design I eventually ended up with in SPGL’s sprite engine is close to perfect :slight_smile: For my games, at any rate.

Cas :slight_smile:

What about your other designs?
Have you made any general purpose designs which work nicely with web apps, games as well as office apps?

I believe this deserves another post.

Reflection within a design.
I’ve found many times that using reflection would cut down code considerably under some circumstances.
However I’ve always avoided it like a plague due to performance reasons, not so much because of design reasons.

If your code could be understood perfectly using some reflection in some circumstances, then why not use it to simplify your design assuming performance wasn’t an issue?

I already use reflection to implement a bean-like XML loader for loading resources from XML files.
I’m trying to find out a good way to use annotations.

The thing is, every single bit of a design is implemented to solve a specific problem. Sometimes some things seem to occur in lots of places, and they become “design patterns”, and people have written some books about it. I myself don’t find the need to read or write these books because I’ve been doing it so long stuff just occurs to me naturally.

There is a problem with patterns in that they can be quite generic and sometimes they are bent a little to make them fit a specific problem and you’ll get some kind of performance problem. Here’s an OOP example: by declaring a parameter to some method to be the generic interface List rather than the specific LinkedList you risk someone passing in an enormous ArrayList instead. If the method performs loads of inserts and deletes on the list, performance will be awful. The design pattern in this case is a very simple idea - always use the most generic interface you can for an OOP system - but the specific problem being solved is actually overridden by a more specific pattern which may not be anticipated by the author. Meh. It makes my brain hurt just thinking about this stuff nowadays.

Cas :slight_smile:

MVC is one of my favorites, it works well for all the stuff I do at work (J2EE Architect) and for my games at home.

M = Model, where is my spaceship, or details about a customer.
V = View, 3D spaceship renderer, 2D spaceship renderer, or a JSP to display customer details.
C = Controller, Clicking the thrust button increases speed, clicking the delete customer button removes my customer from the DB.

Anyway you get the idea, the good thing about this pattern is that you can have many different renderers for the same models, therefore you could have some that use all the latest features of the graphics card, and you could also have one that works on a mobile phone, the rest of the game (in theory) doesn’t need to change.

Andy.

PS: There are many books/sites that can explain MVC in better detail than I did here.