diff --git a/.gitignore b/.gitignore index 0512d3c..e5c244d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ *.~undo-tree~ -*.dSYM~ \ No newline at end of file +*.dSYM~ +*#* diff --git a/docs/#coding-style.md# b/docs/#coding-style.md# deleted file mode 100644 index 017c75e..0000000 --- a/docs/#coding-style.md# +++ /dev/null @@ -1 +0,0 @@ -# These are more like guidelines \ No newline at end of file diff --git a/docs/.#coding-style.md b/docs/.#coding-style.md deleted file mode 120000 index 3297c1f..0000000 --- a/docs/.#coding-style.md +++ /dev/null @@ -1 +0,0 @@ -peisongxiao@PeisongXiao.11477 \ No newline at end of file diff --git a/docs/coding-style.md b/docs/coding-style.md new file mode 100644 index 0000000..105b3db --- /dev/null +++ b/docs/coding-style.md @@ -0,0 +1,39 @@ +# These are more like guidelines + +## Naming schemes +- Use reasonable names, especially for class members +- Use shortened names for local variables +- Use comments to explain if a name doesn't obviously imply what the + variable does + +## Constants and types +- All constant variables should be in all CAPS +- When not needing values to distinguish flags (i.e. the flag is only + there to denote a type, its value can be anything), use **enum**. +- If a template object is used more than once, it is a good idea to + wrap it in a class/struct or use a **typedef** +- If the purpose of a class is solely to store data, use a struct. + +## Object design +- If an object isn't meant to be inherited, declare it **final** +- If a member function has to be implemented individually, declare it + as a pure virtual function. + +## Global variables +- Avoid using global variables at all costs +- Can improve **rng** to be referenced instead of externally exported + +## Functions and local variables +- A function should be at most 40 lines unless it's logically simple + (e.g. has a long switch statement that calls other functions). + *rationale: functions should be short and sweet and let the people + reading them know what it does.* +- Never have more than 4 local variables in the scope of a function at + the same time. + *rationale: a normal human's brain can only keep track of a handful + of things at once* + +## STL library +- Prefer using the STL library over raw data types unless it's a very + simple data type +- Use unique_ptr<> for heap-allocated objects