Sign in to follow this  
popsoftheyear

Private data struct in class

Recommended Posts

Greetings everyone. Is there a generally accepted way to hold private members/methods in a class? In other words, I am working on this wrapper class to simplify the fact that we jump between 2 3rd party imaging libraries and a WIP proprietary imaging library (you wouldn't wanna see the code here...). Now in this class there are quite a bit of members and methods which are used to tie these different libraries together. For the sake of that nice auto-completion dropdown you get in VS2005 (honestly no other reason...), I was considering grouping everything into a private struct (with all members publicly accessible from the classes point of view), since there may possibly be more private functionality than there is public functionality, and this thing is growing fast. Is there a better way to do this? How do others do it? I see many (including STL) use an underscore followed by the name to denote private members and methods and we get the grouping of all private members to the top of the drop down list for free. This however, if I understand correctly, is "reserved" by Microsoft for use... meaning '_' shouldn't be used as a prefix normally. Now I realize that may be a moot point and there shouldn't be a problem with using '_' as a prefix... but there would still be a bit of private members to scroll through that you would never be able to use anyways..... Any thoughts? Is grouping it all in a private data struct a bad idea? What do you all do? I know everyone will have different coding standards but that's why I'm asking. Cheers -Scott

Share this post


Link to post
Share on other sites
It sounds like you are using a facade / composite pattern this is the correct way to go. As for creating inner classes for the sake of VS this is not the best reason I have ever heard and prefixed underscores and prefixed double underscores are reserved according to the C++ standard not just MS.

Share this post


Link to post
Share on other sites
So do you do anything to tell "mark" private data? I realize doing it for the sake of MS's autocomplete/intellisense dropdown is bad reasoning... I can't help but feeling like it will help in a couple ways and hurt in none though...

Your quote is amusing.
[EDIT] I apologize... didn't realize you meant it in such a way. (And did you just rate yourself down?)

Cheers
-Scott

Share this post


Link to post
Share on other sites
Inside a class, you can use a single underscore followed by a lower case letter. A single underscore followed by an upper case letter is verboten. Personally, I mark private members by a trailing underscore.

Share this post


Link to post
Share on other sites
Quote:
Original post by popsoftheyear
So do you do anything to tell "mark" private data? I realize doing it for the sake of MS's autocomplete/intellisense dropdown is bad reasoning... I can't help but feeling like it will help in a couple ways and hurt in none though...


The only thing I would do is to not declare private members/functions in the public interface.
"...we get the grouping of all private members to the top of the drop down list for free." Is this not possible with intellisense or at least Visual Assist?

Correction: Yes that is correct SiCrane 17.4.3.1.2 - Global names.

Share this post


Link to post
Share on other sites
They're kinda old school and stuck in their ways here so Visual Assist is out of the question as far as buying it (Find in Files is THE way to debug code... no comments anywhere... program originally ported from DOS... lotta people worked on it over 20 yrs... advanced stages of copy/paste syndrome... same things many others have to work with too I'm sure). It looks good though... perhaps I will buy myself a copy anyways.

Anyway, fair enough. Thanks both for the information.

-Scott

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