Jump to content
  • Advertisement
Sign in to follow this  
jamesleighe

Protecting Internal Classes

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

Lets say I have a Texture class, and I don't want the gamecode to be able to create one directly, but rather ask the renderer for one.

Now, I can do this by only allowing the gamecode to include an interface to the Texture class.
But now I have interfaces for many classes that don't need them. With the performance hit to go along with it.

Is it worth it to force the use of interfaces only to prevent any direct creation of internal classes?

Sorry if I'm not clear, I am a bit tired.

Share this post


Link to post
Share on other sites
Advertisement
Well you could just make the constructor's non-public and friend the thing that creates them instead. What are you trying to accomplish by making it only creatable through the renderer?

Share this post


Link to post
Share on other sites
A comment is often sufficient. The first time they go to try to construct one of these things, they're going to read the constructor documentation. Mentioning it there would be fine. It's not like the people you're dealing with are malicious.

Share this post


Link to post
Share on other sites

Well you could just make the constructor's non-public and friend the thing that creates them instead. What are you trying to accomplish by making it only creatable through the renderer?


texture is just an example, but for that it's because it's garbage collected

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!