KOffice – TDE office suite
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

93 lines
2.9 KiB

  1. Since 1999, people have been hacking on Chalk. Everyone brought their
  2. own coding style, their own code conventions, their own likes and
  3. dislikes. Me, (Boudewijn that is), I like indents of four spaces, and
  4. no scope prefixes for variables. However, in the interests of
  5. consistency, these are the rules new code should adhere to:
  6. Indentation
  7. With four spaces. Use the default Java indentation
  8. style of (X)Emacs or KDevelop -- also for brace placement.
  9. Includes
  10. Avoid as much as possible #includes in header files; use forward declarations
  11. of classes.
  12. Initializers
  13. Avoid as much as possible initializers in the body of the constructor. Use
  14. initializer lists instead.
  15. Scope prefixes
  16. Use only m_ for class-level variables. No other scope prefixes; no g_, l_,
  17. no 'p' for pointer variables.
  18. Shared pointers
  19. Use shared pointers wherever possible.
  20. Getter/setter
  21. Chalk doesn't use Qt's properties -- yet. If you want to introduce use of
  22. properties, convert any and all classes in Chalk before committing.
  23. Getter/setters are named 'x() for getters and setX(int x) for setters. If you
  24. come across violations of this rule, change the code.
  25. Class naming
  26. If you use a well-known design pattern, name the class according to the design
  27. pattern. All files should start with 'kis_', all classes with the 'Kis' prefix.
  28. In filenames, separate words with an underscore; in classnames use capital letters.
  29. Example: kis_new_class.h/KisNewClass.
  30. The only exception to this rule are interfaces.
  31. Example: kis_tool.h/KisToolInterface.
  32. Function naming
  33. Functions should be named in camelBackedFashion, to conform to Qt's standards.
  34. If you encounter functions in c_style_like_this, feel free to rename. Also:
  35. verbNoun -- i.e., rotateLayer, not layer_rotate. The latter is a true c-ism,
  36. introduced by a language that needs to prefix the 'class' name to every function
  37. in order to have something that not quite OO.
  38. Variable/Parameter names
  39. Variable/parameter names start with an undercast letter. A name composed of different
  40. words is done in camelBackedStyle.
  41. Designer
  42. Chalk has started to use designer. All dialogs and all widgets that have a layout
  43. manager must be done in designer. We don't add code nor add signal/slot connections
  44. in designer
  45. Enums
  46. All enums should be prefixed with 'enum'.
  47. Namespaces
  48. Currently, we only use anonymous (right term?) namespaces for things like undo
  49. commands. For the rest, some classes have a 'Kis' prefix, others don't. This should
  50. be made consistent, and we might want to use namespaces to keep all of Chalk
  51. inside.
  52. Files and classes
  53. It's preferred (and strongly preferred) to have only one class per .h/.cpp file.
  54. (Which is logical, because otherwise you won't be able to keep to the naming scheme.)
  55. Spaces
  56. Keep the source airy and open. (However, maybe I was wrong in wanting spaces around ->...)
  57. Slots and Q_SIGNALS
  58. Prefix Q_SLOTS with slot and Q_SIGNALS with sig: slotUpdateSelection, sigSelectionUpdated.
  59. Boudewijn Rempt