... | ... | @@ -40,10 +40,26 @@ Dead code is bad; it suffers from code rot, and it looks unclean. There are some |
|
|
|
|
|
Any dead code (both files that are unused and blocks of commented-out code) should in principle be removed. If there is a very good reason to keep it around for a while, it must be accompanied by a comment explaining why it is still there, and when it will be removed or enabled again. This comment should point to a ticket so that we do not forget about it.
|
|
|
|
|
|
## Language choice
|
|
|
|
|
|
Kea is written in C++11. For scripting elements, such as tools and more complex scripts, Python is the recommended language. Shell should be used only for basic tasks. If any of the following is true, you should use Python, not shell:
|
|
|
|
|
|
- the task is expected to get more complicated in the future, e.g. parsing list of API calls and generating documentation
|
|
|
- the task requires more complex logic, e.g. building associative arrays that are traversed in various ways
|
|
|
- the task is not small enough that it's done in one ticket and then forgotten. If you expect more devs be involved in the future, use python
|
|
|
|
|
|
Note: for historical reasons, keactrl as well as shell tests are written in shell. On a retrospect, this was a mistake. Both should have been python scripts.
|
|
|
|
|
|
Python has number of advantages of shell:
|
|
|
- it provides access to a very rich set of libraries: JSON parsers, http implementation, process monitoring and more. While all of those could potentially be implemented in shell at great effort, the return of investment is not good.
|
|
|
- good testing support. See pytest, unittest and other tools
|
|
|
- ISC QA has good, multi-year experience with Forge tool that's written in Python. Stork has system tests written in Python, too.
|
|
|
- python does not suffer from the portability problems as much (see bash vs dash vs sh vs tsch vs zsh differences)
|
|
|
- python is inherently more efficient in some cases. There is long term plan to provide hooks in python. Shell based hooks are technically possible now, but are way less efficient, due to having to spawn multiple separate processes for each packet.
|
|
|
|
|
|
# Python Style
|
|
|
We don't use python code anymore in the core code. If you found any leftovers, feel free to remove them.
|
|
|
|
|
|
(note this can change with the RBAC reverse proxy prototype and anyway documentation is built using Sphinx so we have a lot of python code for not core critical code)
|
|
|
We use python 3. Follow [PEP8](https://www.python.org/dev/peps/pep-0008/) if possible.
|
|
|
|
|
|
# C++ Style
|
|
|
|
... | ... | |