Archived

This topic is now archived and is closed to further replies.

Object state?

This topic is 5820 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

How come there is so few posts on the Sotfware Engineering part? Come on guys, it is all about putting it together, or am I one of the few who actually considers this to be more important than the code itself. Anyway, that''s not the reason I''m writing. I have an idea of how to use an object I have and as always would be very appreciative for any comments. Say you have the loop. Check the messages and then: check input, do ther processing and finally flip. Now, I have an object with an off screen map. The surface holding the map is bigger than the screen resolution. I manipulate this surface and blit a RECT equal size of the screen from this surface to the backbuffer before flip() is called. Lets say the user pressed right arrow and wanted to scroll. The keyboard handler calls the map object and the mapobject adjusts its surface to reflect the scroll. Would it be more efficient just to call the map object which only alters the current x,y position (member vars) and sets a flag that this object should run its update function- not changing its surface at all at this time. When the loop continues it comes down to some sort of object manager that checks each object''s flag in a linkedlist or something and runs the update function for each object that requires it. Would you consider this to complicate the process? It does add extra overhead which is not good but I just felt that it might have some advantages? Give me your thoughts...

Share this post


Link to post
Share on other sites
If I understand this correctly, it seems like we are dealing with two issues.

The overall efficiency of the system is a wash. Your second method is slightly more complicated, but the overhead is neglible. Remember when we talk about efficiency we generally need only be concerned with algorithms that have a significant impact on the system, we don''t care that we lost a couple of nano-seconds in this case.. instead we need to balance this against the decision issues that your facing.

If I understand this, your trying to decide whether to immediatly update the internal bitmap buffer that contains your map when the map needs to scroll..or whether you want to put that off for later.

In a single threaded application I don''t see any real benefit to delaying the action. It seems like you have to adjust the buffer at some point, and making the decision as to when you want to do that is really a matter of personal preference.

The real question is that of user feedback. If adjusting the buffer is an expensive process, then we may see some benefits of deferring the adjustment until later. The idea being that the user regains some control of the system while you go off and adjsut it in the background. The system will seem more responsive because it did not have to block waiting for the redraw. Something tells me that the amount of time your going to spend doing that does not warrant extra complexity, because it should still be small enough so that the user does not even notice it.

Share this post


Link to post
Share on other sites
Thanks for your reply.

I think that you are right, it is a personal preference and I will update straight away because the operation is kind of easy. It also makes the code easier to read I think.

Share this post


Link to post
Share on other sites