Jump to content
  • Advertisement
Sign in to follow this  
lordcorm

Observer Design Patter

This topic is 3832 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

Im making an observer system, and i want to only have one function that all the subject send to there observers to update (the "update" function :P), but, the way i want to handle that, is to send a string as a parameter to tell the observer what the update is about. So my question is -- Would it be faster to generate a CRC from the string then pass an integer as the parameter and not a string, so when i get to the other side (the function body) i dont have to do alot of string parsing?

Share this post


Link to post
Share on other sites
Advertisement
Now granted, I don't know exactly what you're dong... but why exactly do you want to pass a string? If you're already OK with passing an int instead, it seems to me that you might as well just use a #define or const int, unless you want it to be user-defined or something...

Share this post


Link to post
Share on other sites
Quote:
Original post by lordcorm
Im making an observer system, and i want to only have one function that all the subject send to there observers to update (the "update" function :P), but, the way i want to handle that, is to send a string as a parameter to tell the observer what the update is about.

So my question is -- Would it be faster to generate a CRC from the string then pass an integer as the parameter and not a string, so when i get to the other side (the function body) i dont have to do alot of string parsing?


What does "updating" do? What information is required in order to "update" the object? Send that information. If you "encode" things - e.g. turing the string into an integer - you'll only have to "decode" them later, and you haven't gained anything. Also, things like CRC lose information. You cannot determine, given only a CRC, what the original string was.

But it's kind of hard to figure out what you're really trying to do. Could we see at least a sketch of the code you're planning?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!