Need code optimization suggestions

Whether you're a newbie or an experienced programmer, any questions, help, or just talk of any language will be welcomed here.

Moderator: Coders of Rage

User avatar
Joeyotrevor
Chaos Rift Cool Newbie
Chaos Rift Cool Newbie
Posts: 62
Joined: Thu Jan 22, 2009 6:24 pm
Programming Language of Choice: C++

Re: Need code optimization suggestions

Post by Joeyotrevor »

dandymcgee wrote:
Joeyotrevor wrote:
dandymcgee wrote:
I've always wondered about the "C" in "CItem" habit (seen it a few other places), I'm guessing this is a general way of saying something is a container?
Nah, it's just in case they forget it is a class. IMO it's kinda stupid.
Wow seriously? That's like starting variable names with "i", "f", and "d"... :|
Exactly.

Code: Select all

eb 0c 48 65 6c 6c 6f 20 77 6f 72 6c 64 21 31 d2 8e c2 30 ff b3 0a bd 02 7c b9 0b 00 b8 00 13 cd 10 eb fe
User avatar
Netwatcher
Chaos Rift Junior
Chaos Rift Junior
Posts: 378
Joined: Sun Jun 07, 2009 2:49 am
Current Project: The Awesome Game (Actual title)
Favorite Gaming Platforms: Cabbage, Ground beef
Programming Language of Choice: C++
Location: Rehovot, Israel

Re: Need code optimization suggestions

Post by Netwatcher »

GyroVorbis wrote:How would one "optimize" code in a header file? There are no algorithms, just data structures. We also can't see how you're using the data structures, so there isn't a lot we can do to help.
I'm sorry but I find it hard to write my ideas in English, the language is too limiting for me...(it's hard to translate my thoughts into English)


Anyway... I did mean a container for ITEMs(who are containers)
I'm creating items by simply pushing back ITEMs into the vector, each with different properties, in the "game" itself it should retrieve this information for a specific item and handle it for whatever the case is...
what kinds of info are you looking for?

Oh and Optimisation = fastest Processing time with lowest Memory usage. ;)

And why do you argue about the name I gave the frigging class? it's just a NAME!
"Programmers are the Gods of their tiny worlds. They create something out of nothing. In their command-line universe, they say when it’s sunny and when it rains. And the tiny universe complies."
-Derek Powazek, http://powazek.com/posts/1655

blip.fm DJ profile - http://blip.fm/Noobay
current code project http://sourceforge.net/projects/vulcanengine/
User avatar
MarauderIIC
Respected Programmer
Respected Programmer
Posts: 3406
Joined: Sat Jul 10, 2004 3:05 pm
Location: Maryland, USA

Re: Need code optimization suggestions

Post by MarauderIIC »

Netwatcher wrote:
dandymcgee wrote:
MarauderIIC wrote: dandy: the point of the encapsulation in NetWatcher's code is, looking at the use, so that only the item container (CItem) can make items. This enforces a constraint of "every item created must be in the item container", since the struct cannot be accessed outside of the class (since it's in the private section). Since this is the case, NetWatcher, it looks like you might want to make CItem follow a singleton pattern, or implement CItem inside your Game class. It wouldn't make much sense to me to enforce items to be in a container while also allowing more than one container.
That makes perfect sense. I wasn't thinking of CItem as a container, but rather a single item with the struct simply storing a single item's properties. But if CItem is a container and the internal struct is defining the individual items within the container then the implementation is a bit more logical. ;)

I've always wondered about the "C" in "CItem" habit (seen it a few other places), I'm guessing this is a general way of saying something is a container?
Container? waa.... no... just in case I want to use Item for something else...(C-class)
Use it for what? Items? Oh, wait.
I realized the moment I fell into the fissure that the book would not be destroyed as I had planned.
Post Reply