Design Principles

Revision as of 12:46, 17 December 2009 by Chriswaterguy (talk | contribs) (minor grammar fixes)
Jump to: navigation, search
  • If only several simple APIs of another big library are needed, try to extract them and add them to your program instead of depending on the whole library whenever possible. (Beware of license)
  • Only use libraries from other desktops when they are small or efficient enough and have few dependencies.
  • Only create a daemon if there is a really good reason.
  • Basic configuration options of applications should be editable via GUI whenever possible.
  • Keep the user interface simple and intuitive. Never design some geek-style GUI.
  • Consider the conventions of both GNOME and Windows, and try to follow the habit of most users. Do not deliberately make the GUI quite different only because you want to be different from Windows. Usability is always the top one concern. Windows might not be good in some areas, but like it or not, most computer users in the world are used to it. Trying to fight your users is apparently unwise.
  • Try to shorten the startup time since this greatly affects user experience.
  • Try to keep maximal compatibility with lower gtk+ versions (gtk+ 2.6 is preferred). Try to make features requiring higher gtk+ versions optional with proper conditional compilation and compatibility macros.Gtk+ version can be check in C program like this:
#if GTK_CHECK_VERSION( 2, 10, 0 )
    /* write some gtk+ 2.10+ specific stuff here */

Coding Styles

Currently, coding style of all lxde programs are different. However it's good for a project to have consistent coding style in all the programs. Personally, my coding style is like this:

#include "some-header.h"
void function()
 if( value )
   char str[10];
   for( i = 0; i < 10; ++i )
     str[i] = '0' + i;
   str[i] = '\0';
 else if( value2 )
   do_other_things( param1, param2, param3 );

1. use fixed 4 space indentation instead of tabs.

2. do not attach { to end of line and put it in a seperate line.

3. do not indent { and }.

4. different words in a filename should be seperated by hyphen. (ex:main-window.c, not mainwindow.c)

5. add spaces between operaters and their operands.

6. no space between function name and ().

7. add spaces between parameter list of a function and the () outside it.

Some rules are not strictly followed, either. If anyone found those rules quite annoying, the project is open for discussion. Anyways, we can use some formatting tools such as astyle to reformat all the source code.