Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

Inheritance VS single class - whats better?

$
0
0
Hello, I'm currently working on a game library [DLL] with XNA.
And well, I was wondering what is better/more efficient:
having a single class, for this purpose lets call it GameObject,
or multiple classes arranged like so:
Obj_Data
Obj_Painter (Inherits Obj_Data)
Obj_Updater (Inherits Obj_Data)
Obj_PaintUpdater (Inherits Obj_Data) and so on.
Obj_Char_Anim (Holds a name, index and a source rectangle)
Obj_Animation (Inherits Obj_PaintUpdater + contains a list of Obj_Char_Anim)

This is the code I'm using right now, if it helps in any way:
Obj_Data
Obj_Updater
Obj_Painter
Obj_PaintUpdater
So far, Obj_Char_Anim and Obj_Animation are only in the planning process, so I have nothing to show regarding that.

P.S. If my question wasn't quite clear enough, this is it again:
What is more efficient or rather, more accepted in the c# community:
A single class that does everything (The so called GameObject)
or, multiple classes that inherit from one another (like what I did with my code)?

Thank you in advance, ~Dardas.

Viewing all articles
Browse latest Browse all 51036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>