Coding rules

From DeSmuME
Jump to: navigation, search

Here are some coding rules that are intended to keep DeSmuME's code clean. Do your best to respect them. Otherwise, if DeSmuME's code becomes too much messy, noone will want to work on it anymore and it'll die.


Contents

1. General rules

  • Do not commit code that breaks compilation. If it does, fix it the soonest you can. If it breaks compilation under another platform and you can't fix it, notify the other coders.
  • Please try to keep the code clean.
  • If using global variables, make sure the names you give them aren't already used. Even if they're static variables.
  • The rule above also applies for constants and defines.
  • Avoid super-condensed code like: if(foo==bar){bar++;dosomething();} . Putting spaces and linebreaks helps making your code readable.

2. Indentation

The Win32 coders use Visual C++, which uses 4-space wide indentations by default. However, most Linux text/code editors use 8-space wide tabs by default. In short: You can use either tabs or spaces, but DO NOT mix them. The result will look completely messed up on editors which use different tab width from yours.

3. Rules specific to the Windows port

3.1. Editing the Resource file (resources.rc)

The Resource file contains multiple versions of the dialogs, one per supported language. To not break the translation system, be sure to respect those rules:

  • When adding or modifying a dialog or menu, start by working on its English version. Once you finished, copy your changes to the other versions of it. If you can translate the strings to the target language properly (NO GOOGLE/WHATEVER AUTOMATIC TRANSLATOR!!!), do it; otherwise, just leave them in English. The person who's in charge of the translation will someday translate those untranslated strings.
  • If you wish to make a translation, be sure to always be around when your translation needs to be updated, so that we don't end up with a translation which is half English. If that happens and you don't show a sign of life, your translation may be deleted.
  • When translating, be sure the translated strings fit in their respective controls!
  • Do not use any other resource editor than Visual C++'s one. All those third party resource editors rewrite the whole resource file when saving, therefore they will cause conflicts and other shit.
Personal tools