My application now becomes an oversized giant. There's a small lag and performance drop as the code keeps getting bigger. I suspected that it's all because of the unorganized and poor OOP implementation in my part. Here's what I did (and didn't) do. Oh and FYI, I'm making a simple game using SDL:
1. I load all the bitmaps into SDL_surfaces in the memory (200 megs of images BTW). And from those surfaces, I created objects like background, sprites, etc.
2. Didn't do any design pattern whatsoever. I created classes when I think I need one.
3. No inlined, or static function / variable
4. Few assert and exception handler
5. Most of the variables are referenced by pointer (eg. surfaces, sprites, etc)
6. My animation routine is like this:
1. Blit the whole background
2. Blit objects
3. Flip the surface
4. Loop to 1
The code itself is one big mess. My questions are:
1. Is the performance boost from an inlined function significant to the whole application's performance?
2. If I want to create objects / variables that can be accessed by multiple objects and if the accessed objects / variables were changed, the change will be carried out to all the accessing objects, is it better to use static or a reference by pointer ? What's the benefit of static over a reference by pointer (or vice versa)?
3. Do unused functions and variables in a class have any impact to the performance?
4. Does any of you have any advice to help me make a better code?
Thanks alot in advance.



LinkBack URL
About LinkBacks



. Seriously though, first find parts that are obviously lagging down your program, and rewrite those, then when you can't tell as easily look into profiling your code to see where the bottlenecks are and work on fixing those up. This is where design patterns are something you need. That way you make interfaces to areas of your code, and can change the implementation without worrying about the affects on the rest of your code.
CornedBee