to use interfaces or not to use interfaces (where ever possible) ?

I was wondering if its inefficient to use interfaces, considering you would want to squeeze every bit of performance from a game, interface calls are much slower than direct calls.

regards

Fluxtah

[215 byte] By [Fluxtah] at [2007-12-26]
# 1
I say use them as much as possible... they help with design and that can go a long way in dev time and performance.
vidalsasoon at 2007-9-4 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,XNA Game Studio Express...
# 2

I am all for interfaces, however I mainly program enterprise applications where I can sacrifice performance for extensibility.

If you consider that interface calls are far slower than direct calls, if your game is all made up of interface calls it would seriously sacrifice performance.

I noticed that space war does not use many interfaces, I wonder if this was the reason.

Fluxtah at 2007-9-4 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,XNA Game Studio Express...
# 3
It's not that much slower. The problem is not many people know how to use them well and are thinking of performance way too early in the dev stage.
vidalsasoon at 2007-9-4 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,XNA Game Studio Express...
# 4

yeh your right, they are only a little slower, I guess space war is not that complicated to warrant heavy use of interaces.

Fluxtah at 2007-9-4 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,XNA Game Studio Express...
# 5

I suggest reading some interface and base-class design guidelines in the MSDN library[1]. There are many reasons to use and not to use interfaces -- it's going to be largely unique to your application. Otherwise, there are some common recommendations and rarely is performance an issue.

1: http://msdn2.microsoft.com/en-us/library/ms229013.aspx

GregChristensen at 2007-9-4 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,XNA Game Studio Express...
# 6

The main issue I was concerned with was performance, but I was mistaken as the performance factor is practically insignificant, I think I was getting confused with the performance of delegates and dynamic invocation which do suffer a significant performance hit.

Fluxtah at 2007-9-4 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,XNA Game Studio Express...
# 7
Interfaces are fast (as fast as virtual functions), whereas QueryInterface, or dynamic casting (foo as Bar), or delegates/events, are a lot slower. If you know that you'll only ever want to ask for interfaces A, B and C from some base interface I, you would probably do better to expose getA()/getB()/getC() as virtual methods, than trying to do that exposition through some QueryInterface style function.
JonWatte at 2007-9-4 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,XNA Game Studio Express...