Jump to content
  • Advertisement
Sign in to follow this  
Estauns

[.net] Class Properties Within The Class - Anything Wrong?

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

Is there anything semanticallyl wrong with using class properties within the class itself? One of my properties (get) calculates a value. I also need this value within the class itself. Is it okay to use this.Property or is a GetCalculatedPropertyValue() the more semantically correct way to do this?

Share this post


Link to post
Share on other sites
Advertisement
There is no reason to not use the properties, especially if using the properties is making sure that you do everything correctly. For instance, in one of my GUI controls I always manipulate the size with the Size property, because that makes sure to lock the vertex buffer, resize, unlock, etc.

Share this post


Link to post
Share on other sites
I think if you are talking about using a Property (property or a la get and set methods) instead of accessing the private member is a much better way to code if that specific member needs special values such as an integer that can only be between 0 and 5. The set/property can check against invalid values, but for regular cases like setting transparency or something of your object, like a boolean, might as well just access the private member.

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!