Project

General

Profile

Actions

CodeReview Guideline

Guidelines before you push code review

  1. use const as possible as you can, such as

1.pass built-in type by value
2.pass pointer(include smart pointer) by value
3.pass small object by value only if you know it is a small object such as LTPinld, else always passed by &
4.pass other types by const& if you will not change it.
5.member function should be marked as const if you do not change other members in this function
6.use const for return value only if the type is not a built-in type

  1. use a meaningful variable/function name and do matched things

1.use verb + n for function name
2.use n + n ... for variable/class name
3.if the function name starts with is/has, it should be return a bool value
4.if the function name starts with get, it should be return a value
5.the function name should tell others what does the function do

> # !!!!Do not use ambiguous name !!!!!

  1. avoid re-inventing the wheel

1.if some same codes were write more than once, we should use a function to do it.
2.use std container/algorithm as if as you can
3.use CM_ENUM_HELPER_DECLARE/CM_ENUM_HELPER_lMPL for any enum class
4.use NAMED_TUPLE instead of pair which could take more information such as each member name
5.unify those similar code with template or design pattern

  1. write readable code with clear logic

1.idealy each function should not beyond one page of your editor
2.a huge function is very hard to understand for reviewers, split it into many small functions with a serials meaningful function name is better
3.if it is still hardly to understand, plz add essential comments

  1. avoid to write meaningless code

1.check the invalid condition as earlier as you can in the begining of a function
2.just defined a variable when you really need it(idealy use it in the next line after the definition)
3.only export c++ functions to python when you really used it in the python
4.only do abbreviation if the abbreviation is not unique !!! a clear long name is always better than a short confused name !!

  1. unify the coding style in a single file

1.use the same blank space surround the operator
2.use the same name style for variable and function
3.do not use number in any variable/function !!!
4.always use float instead of double, which is enough for 99% case

  1. All partition based/chunk based structure should provide merge function and export to python, merge function must return the reference of itself!!!

  2. Always use forward declaration instead of include headers, template class is the only exception

  3. Do not merge data one by one, must use merge_data_in_paralle !!!

  4. Always add noexcept for those class constructor to avoid huge core dump file

Updated by jun chen 3 months ago · 1 revisions