Sign in to follow this  
Mehdi_H

Hiding pointers

Recommended Posts

Mehdi_H    122
Hello I'm developing a C++ "ResourceManagement" library as a part of an educational game engine. The library will develop as collection of classes Like: ResourceManager* rsm = NULL; Resource* rs = NULL; rs = rsm->Get_Mesh( "filename.x" , true ); As you can see in the sample code above , objects didn't allocate using "new" operator , and they also managed by "ResourceManager" class & mustn't be "delete". This is known that target users are not experienced in C++ programming , So I want to do some thing to hide pointers from them to not "new" or "Delete" objects & limit them to use the framework. How Can I do this? Do you suggest some "typedef" or what? please share your experiences with we. thanx

Share this post


Link to post
Share on other sites
Billr17    437
Quote:
Original post by Mehdi_H
This is known that target users are not experienced in C++ programming , So I want to do some thing to hide pointers from them to not "new" or "Delete" objects & limit them to use the framework.


Some random thoughts on your situation:

Have you considered using a scripting engine to expose this functionality to the end user? Using a scripting language would allow you to hide a lot of the tedious and advanced functionality of the C/C++ languages. Additionally, the end user would not be required to compile the source code in order to see their results. It could be as simple as them using notepad to create a few files that are saved into some specified folder. The CPython and Lua scripting engines (for example) provide a way for you embed them in your software. Additionally they also provide a way to expose your objects, functions, etc to the end user.

What is your target audience? How much experience with programming do they have? We would be able to make better suggestions if we knew.

Share this post


Link to post
Share on other sites
Ever heard of RAII? Even professionals don't like dealing with pointers it seems.

BTW: What form of learning are you planning on offering? If these are simple beginning programmers, then I like the scripting idea. If you're using C++ because these programmers should be able to handle doing more low-level code, then why shield them from resource acquisition? Why not introduce them to it, or at least practice them in it?

I know they might leak resources, but you can also catch this and inform them of the problem! Or, let them make their own bed, afterwards forcing them to lay in it.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this