Difference between revisions of "Coding Style"

From Mineserver Wiki
Jump to navigation Jump to search
      /* private instance vars etc go here.*/
      /* private instance vars etc go here.*/
    };
    };
−
** '''Instance variables''' should usually be accessible through getter and setter methods and thus be private. In some cases having them public is fine (e.g. when they're accessed all over the place and modifiying them happens all over the place as well. Usually this is the case for "dumb classes" used as pure data structures. We should consider using a '''struct''' instead for these cases.). Also, don't use prefixes for public instance variables, since it's ugly to use. For private instance variables we could choose to use either '''_foo''', '''m_foo''', '''mFoo''' etc. I personally prefer '''_foo''' and have a getter method be just '''foo()''' and a setter '''setFoo()'''.
+
** '''Instance variables''' should usually be accessible through getter and setter methods and thus be private. In some cases having them public is fine (e.g. when they're accessed all over the place and modifiying them happens all over the place as well. Usually this is the case for "dumb classes" used as pure data structures. We should consider using a '''struct''' instead for these cases.). Also, don't use prefixes for public instance variables, since it's ugly to use. For private instance variables we could choose to use '''m_foo''' and have a getter method be just '''foo()''' and a setter '''setFoo()'''.
* '''Namespaces''': We probably should use them.
* '''Namespaces''': We probably should use them.
* '''Codeblocks''':
* '''Codeblocks''':