This repository has been archived by the owner on Mar 3, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 45
My way of programming
jlppc edited this page Sep 2, 2017
·
8 revisions
I don't force you to follow it, but I write here my way to program, so you will be able to understand some things in my code. If you want to participate to the game, it's better for me that you follow theses rules, but I don't force you. It is just for me. Because I don't know the way of programming of other programmers, I could have written some generalities. I hope you won't hold it against me.
- Sorry for the purists, but I mix C and C++. It allows me to have more features, and some other things. I use the C++ more like a improvement of the C than a real new language (Even if I know that the C++ is a real new language)
- The strings that appears on the screen are saved in a files that will be read by the namespace StringKeys, this allows a translation of the game.
- The getters returning a boolean are called more ofter isVarName and not getVarName.
- I practically never use boolean setters. If I need to modify a boolean, I put in in public, because, in my opinions, the booleans don't need to be verified. For all other types of variables, I use setters if I need to modify them.
- Obviously, if a boolean is public, I will not create a getter for it.
- I use the convention "camelCase". I never use underscores, except for defines or constants.)
- Some of the variables are in french, or a mix of french and english. I try to not create french-named variables since the internationalization of this project. If there is a french variable that you can't understand, I could have put a english commentary translating this variable, or else, warn me and search on the internet (Sorry).
- All the objects-related comments are in the headers, and all the code-related comments are in the sources.
- Sometime, you can see commentaries in this format in my code //->Word. It allows me to have some information in my code, to specify something to the element pointed. Here is the list of the words I use :
- NoDoc : Nothing on this bloc will be documented.
- PureVirtual : Indicate that the method or the class is pure virtual.
- Enum : Indicate that the namespace is an enumeration.
- EnumClass->namespace : Indicate that the class is used in an enumeration. "namespace" is the name of the enumeration.
- WaitEnum->namespace : Indicate that the variable wait for an enumeration. "namepsace" is the name of the enumeration.
- DontUse : Indicate that the pointed object must not be used.
- JustUse->Class : Indicate that the pure virtual method is used only by one or several of daughter classes, but not for all. "Class" indicates the classes that use it.
- Useless : Indicate that the object is totally useless.
- Deprecated->Use : Indicate that the object is deprecated and it is better to use "Use"
- Final : Indicate that the class or the method must not be inherited or redefined.
- I don't use C++ enumerations, that I don't find them very practical, so I use constants on a namespace.
- Sometimes I need methods or variables in each element of an enumerations. In this case, I create a class wich will be the type of the enumeration and there will be "//->EnumClass->namespace" before the enumeration, indicating this is the class of which enumeration.
- All my variables in an enumeration class are public, but constants.
- when I want to create a string which is the string for an another variable, I often name it "varNameS".
- I try to create macros for the repetitive creation of objects, like attacks or OpMons. It allows me to do it much more quickly. So I create A LOT of macros (Maybe too much).
- I use the .h files for C headers, .hpp for C++ headers and .hxx for headers which only contains preprocessor instructions.
- I comment constructors in the code only if it is really useful. I try to make the parameters' names explicits.