camelCase
The Case of the Mysterious Camel.
- Reaction score
- 362
When I want to restrict access to certain class members, I use protected members by default.
This is so I can derive from that class easily without worrying about being unable to use methods/variables from the base class.
I hardly (if ever) use the 'private' access modifier and only use it if I'm sure I only need to make a method/variable accessible to that class and that class alone.
I thought that everyone did what I do until today's programming class at school today.
The lecturer was saying that you should do the reverse.
Make all members/methods that you want to control private and make it protected only when you want to work with inheritance.
This got me a lil' confused so I'm here asking for opinions =x
It probably doesn't matter and is probably up to the programmer but which convention is more widely used and why?
And is one convention really better than the other?
[EDIT]
I might as well toss in another question about singletons.
What's the difference between a singleton and a class with all members/methods static?
This is so I can derive from that class easily without worrying about being unable to use methods/variables from the base class.
I hardly (if ever) use the 'private' access modifier and only use it if I'm sure I only need to make a method/variable accessible to that class and that class alone.
I thought that everyone did what I do until today's programming class at school today.
The lecturer was saying that you should do the reverse.
Make all members/methods that you want to control private and make it protected only when you want to work with inheritance.
This got me a lil' confused so I'm here asking for opinions =x
It probably doesn't matter and is probably up to the programmer but which convention is more widely used and why?
And is one convention really better than the other?
[EDIT]
I might as well toss in another question about singletons.
What's the difference between a singleton and a class with all members/methods static?