M
Mythran
In C/C++ for MUDs that I used to work on, I'd use the following defines:
#define IS_SET(flag,bit) ((flag) & (bit))
#define PLR_ISALIVE (1 << 0)
#define PLR_THIEF (1 << 1)
#define PLR_LOADFIRST (1 << 2)
To see if a player "is alive", we'd check the PLR_ISALIVE bit:
IS_SET(flag, PLR_ISALIVE)
where flag is the number of the combined flags (IE: flag |= PLR_ISALIVE; flag |=
PLR_THIEF.
Now in VB.Net, a Player Class could be made that simulates the above using
bitwise operaters....I'm wondering what the cost would be to use properties
instead:
Class Player
' Private Members
...
' Properties
Public Property IsAlive() As Boolean
Get
Return mIsAlive
End Get
Set
mIsAlive = Value
End Set
End Property
' et cetera
End Class
Is there a significant difference? Lets say there "could" be roughly 100-200 of
these properties...this exceeds the limitations of the bitwise comparisons using
the old method in C/C++ (could only use up to 32 bits). So, that advantage for
using Class properties instead is already visible. Others would be
maintainability, easier reading and understanding.
So, cost performance. What type of gains or otherwise would I get when using
properties vs bitwise storage (IE: Memory consumption, processor usage, et
cetera)?
Please don't go out of yer way to test, just need something off top of yer heads
THanks!~
Mythran
#define IS_SET(flag,bit) ((flag) & (bit))
#define PLR_ISALIVE (1 << 0)
#define PLR_THIEF (1 << 1)
#define PLR_LOADFIRST (1 << 2)
To see if a player "is alive", we'd check the PLR_ISALIVE bit:
IS_SET(flag, PLR_ISALIVE)
where flag is the number of the combined flags (IE: flag |= PLR_ISALIVE; flag |=
PLR_THIEF.
Now in VB.Net, a Player Class could be made that simulates the above using
bitwise operaters....I'm wondering what the cost would be to use properties
instead:
Class Player
' Private Members
...
' Properties
Public Property IsAlive() As Boolean
Get
Return mIsAlive
End Get
Set
mIsAlive = Value
End Set
End Property
' et cetera
End Class
Is there a significant difference? Lets say there "could" be roughly 100-200 of
these properties...this exceeds the limitations of the bitwise comparisons using
the old method in C/C++ (could only use up to 32 bits). So, that advantage for
using Class properties instead is already visible. Others would be
maintainability, easier reading and understanding.
So, cost performance. What type of gains or otherwise would I get when using
properties vs bitwise storage (IE: Memory consumption, processor usage, et
cetera)?
Please don't go out of yer way to test, just need something off top of yer heads
THanks!~
Mythran