Jump to content
  • Advertisement
Sign in to follow this  
Quat

drawing program design

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

I am working on a drawing program with various tools that lets the user manipulate geometric objects. I have a class for each tool and the application keeps a pointer to the "active" tool. I store the data (a list of geometric objects) in a "document" class instance. 1. The various tools need access to the list of objects (so they can select and manipulate). So I am going to pass a reference to my application's document instance. Should I make the Tool classes friends with the document class, or provide a public interface? 2. Each tool has a graphical depiction as well. I was going to have each tool class responsible for loading its graphic resource. Is this a good idea, or should I allocate the resources in one place and pass references to the resources to each tool?

Share this post


Link to post
Share on other sites
Advertisement
Quote:

1. The various tools need access to the list of objects (so they can select and manipulate). So I am going to pass a reference to my application's document instance. Should I make the Tool classes friends with the document class, or provide a public interface?

I would recommend against using friend classes, if it can be avoided. I personally would go with the second option, or even provide a separate manager class used to store and manage the list of objects. ...This is assuming I understand the question completely.

Quote:

2. Each tool has a graphical depiction as well. I was going to have each tool class responsible for loading its graphic resource. Is this a good idea, or should I allocate the resources in one place and pass references to the resources to each tool?

It is usually better to have all resources managed within a single location, and have the other classes request resources as needed. So, I would go with your second option here.

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!