Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Naming convention for variables to avoid using reserved words [closed]

I was wondering if there is a naming convention for variables that represent a reserved word. For example, I have class called Video and this video must contain a boolean defining whether it's private or not. Since private boolean private;would not work, I wonder what the best option was.

  • mPrivate
  • _private
  • isPrivate
  • notPublic
  • ...

Any suggestions?

like image 692
dumazy Avatar asked Mar 12 '23 01:03

dumazy


1 Answers

If you can think of a two-word name, you're clear of any conflict:

  • private -> isPrivate
  • new -> newItem
  • ...

Plus, it will often be more readable.

The only common name conflict I'm seeing regularly is the class -> clazz mentioned above.

like image 109
Jiri Tousek Avatar answered Apr 06 '23 00:04

Jiri Tousek