Stendhal code design

出自gamedev
於 2018年12月14日 (五) 14:36 由 imported>Test 所做的修訂 (创建页面,内容为“{{Stendhal code design}}{{Navigation for Stendhal Top|Developing}}__NOTOC__ This page gives a little overview about the Stendhal code. == Development Environment ==…”)
(差異) ←上個修訂 | 最新修訂 (差異) | 下個修訂→ (差異)
跳至導覽 跳至搜尋

Template:Stendhal code design


This page gives a little overview about the Stendhal code.

Development Environment[編輯]

Stendhal is completely open source. So you can download the source code and have a look. If you plan to modify it and contribute to the project, we suggest that you use the Eclipse IDE and checkout the latest development state from our version control system.

There are good tutorials to get you started with Eclipse.

Finding your way around the Code[編輯]

The next step is to find your way around the code. The Stendhal code base is roughly divided into the server, client and a little code that is used by both:


Coding Standards[編輯]

We try to follow SUN Java code convention, in order to create code that feels familiar to many developers.

Despite this:

  • We use tab for all indentation. (One tab is equivalent to 4 spaces for display purpose.)
  • We do not stick too closely to line length.
  • We always use blocks in if-statements and loops, even if the block only consists of one single statement:

if (condition) {
    method();
}

Avoid evaluation and assignment in the same line like:

  • ternary operators, for example in:
 String y = x==null ? "NULL": x.toString();
  • post-increment/decrement operators as in:
 if (idx++ == 10) {
   ...
 }