Menu

Writing Rules

Nicolas Hainaux

/!\ this is a first draft
Back

We'll try to write "clean" code. It was not the case at the beginning, but things change. Any help to enhance the code, to make it cleaner and easier to read, is welcome.

We try to follow these rules :

  • All the code should be written in python to avoid complexity and dependencies. There may be exceptions for some parts (like the gui)

  • All the code is written in english

  • The code have to be modular and object-oriented to give the maximal flexibility to reuse each component

  • Everything has to be documented. First, all classes, functions etc. have to be commented for Doxygen, as soon as they are created. And sometimes some complicated algorithms need long explanations : no problem, write as long as necessary.

  • The PEP 8 Style Guide for Python should be a reference

Some personnal choices :

  • The names of the variables should be long enough to be clear and understandable. Doesn't matter if they take space, the code must be as easy to read as possible

  • All fields of any class are named with a single leading underscore, like in _field ; they should never be accessed directly. Instead, there is an associated property having the same name without the leading underscore, this gives a 'read-only' access to the field content and will prevent from assigning a field. A setter must be used explicitely (no setter associated to the property).


Related

Doc for dev: Home

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.