69
votes
Accepted
When is it appropriate to introduce a new layer of abstraction into a class hierarchy?
I've built a 2D roguelike from pretty much scratch, and after lots of experimentation, I used an entirely different approach. Essentially an entity component architecture.
Each game object is an ...
47
votes
Accepted
What's the proper way to model this real-world activity that seems to need circular references in OOP?
I've been wrestling with a problem in a Java project about circular references.
Java's garbage collector doesn't rely on reference counting techniques. Circular references do not cause any kind of ...
47
votes
When is it appropriate to introduce a new layer of abstraction into a class hierarchy?
This is why we often like interfaces over inheritance: Many real-world problems cannot be modeled in an object hierarchy.
interface IMove
{
// returns an intermediate location chosen with
// ...
22
votes
What's the proper way to model this real-world activity that seems to need circular references in OOP?
Granted, circular dependencies are a questionable practice from a design point of view, but they are not prohibited, and from a purely technical point of view they are not even necessarily problematic,...
14
votes
Accepted
Is it a good idea to experiment with design patterns?
People have experimented with different mechanics of implementing a design pattern in the past with differing results. For example, the definition of a singleton is that there is only one instance of ...
13
votes
Accepted
TCP or UDP for a multiplayer game?
Depends on if you're talking about peer-to-peer, client/server with the users running the server, or client/server with a data center running the server. Only in the latter-most case is the internet ...
12
votes
Accepted
Test Driven Development for Complex Games
Unit tests don't test gameplay. There's no programmatic criteria to see if a game is fun, or a level is the right difficulty. Unit tests will test that your roguelike mapgen actually produces a level ...
12
votes
Is it a good idea to experiment with design patterns?
No.
Design patterns are not building blocks. If you are trying to 'experiment' with them, you are most likely trying to apply them in situations that don't make any sense.
Instead, you should ...
11
votes
Is software testing different when we are dealing with game development?
Modern games are actually a ton of creative art content developed using an in-house or proprietary game engine. The engine itself is unit testable for most part (rendering, geometry, physics, AI ...
10
votes
Enemy AI for classic game Bubble Bobble
"The best algorithm to achieve this"? Define "best". A simple A* algorithm will generate the most efficient possible path for an enemy to take to reach the player, but would you really want to play ...
10
votes
What's the proper way to model this real-world activity that seems to need circular references in OOP?
Game theory treats games as a list of previous moves (value types including who played them) and a function ValidMoves(previousMoves)
I would try and follow this pattern for the non UI part of the ...
9
votes
How to pick a random move/action/element non-probabilistically?
Maintain and update the list of possible moves to pick from.
Changes to this list will be small per move on average and often localized to where the piece was put.
9
votes
Accepted
Algorithm for calculating a bullet path to a target with max. 2 ricochets
Given a direct line of sight, the problem is obviously trivial. However, we are dealing with reflection. Properly finding out which parts of the scene can be seen is challenging when implementing ...
9
votes
How to convert a possibly ever-increasing number to a finite scale?
Simple: you start with f(x)=1/x, which goes down to zero when x goes to infinity. Now you want this approximate a constant c from below, utilize it this way:
f(x)= c - 1/x
From your example I guess ...
9
votes
How to ensure a user isn't using a hacked client
NEVER TRUST THE CLIENT!
No seriously NEVER TRUST THE CLIENT!
Third time so you remember NEVER TRUST THE CLIENT! Customer service corollary: The customer is lying!
You need to do all important ...
9
votes
When is it appropriate to introduce a new layer of abstraction into a class hierarchy?
I would follow your first option, but then use the strategy pattern for the different move styles. This will allow you to swap move styles and alter moves styles easier moving forward.
So you’d have ...
8
votes
Distributed game development and security of source code
Rights and capabilities are very different. In fact, legal rights were invented largely because access issues couldn't be solved by enforcing technical capabilities. Sure, we put locks on our cars and ...
8
votes
What's the proper way to model this real-world activity that seems to need circular references in OOP?
The standard way of removing a circular reference between two classes in object oriented programming is to introduce an interface that can then be implemented by one of them. So in your case, you ...
8
votes
Accepted
Is this OOP class hierarchy too deep?
I would have your objects implement interfaces like ICharacter, IEnemy, IHorizontalMover. The relevant design guideline is known as Favor Composition over Inheritance, and it should allow your design ...
8
votes
When to lock an object in a game
Whenever two or more threads need to change the same object and potentially at the same time, you need to ensure that the object remains in a consistent state making it synchronized.
Apparently, it'...
8
votes
Why don't audio engines already process audio more realistically?
There's no technical reason why any of this couldn't be done. Processing of this depth is already done on the images the game displays (although not in quite the same way).
The problem is not so ...
8
votes
How can a html 5 game made licensed?
The usual solution is to put part of your game logic on a server somewhere and have your game communicate with it using AJAX or similar.
In the server code you can check for license keys.
In short, ...
8
votes
Accepted
Optimal Immutable Data Structure for Highly Dynamic Particle System
Immutable data structures are best suited for systems where
the majority of data managed by an application stays unchanged (or can be modeled in a way so it stays unchanged)
the changes to the data ...
8
votes
When is it appropriate to introduce a new layer of abstraction into a class hierarchy?
The answer to your main question:
in general, when is it appropriate to introduce a new layer of
abstraction at the cost of complicating the program architecture?
is relatively simple and ...
7
votes
Accepted
Handing Off A Unity Project
With the exception of people sunk in the real programmer syndrome, no one is going to disregard you for using Unity. Unity is a framework, like many others, that helps you make software. Saying that ...
7
votes
Algorithm for calculating a bullet path to a target with max. 2 ricochets
Just extending Karl Bielefeldt idea for a 2 walls reflections:
A and B are given (the tanks). You first must list all walls that A can see and a list of all walls B can see. Then you make pairs where ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
game-development × 234design × 24
design-patterns × 23
c# × 22
architecture × 20
object-oriented × 20
c++ × 20
java × 18
algorithms × 16
javascript × 12
android × 11
object-oriented-design × 10
python × 9
artificial-intelligence × 8
data-structures × 7
games × 7
programming-languages × 6
mvc × 6
performance × 6
networking × 6
opengl × 6
web-applications × 5
ios × 5
math × 5
html5 × 5