Whitespace

From NWN Lexicon
Revision as of 11:35, 21 August 2012 by Dood (talk | contribs) (Created page with "=Whitespace= Using whitespace is a matter of preference depending on the developer. It is recommended that white space is used to make your code more legible. <br /> ...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Whitespace

Using whitespace is a matter of preference depending on the developer. It is recommended that white space is used to make your code more legible.


Using tabs (or spaces) to indent blocks of code helps in the readability. Take, for example, the following:


if (bCondition) someFunction(TRUE); else someFunction(FALSE);

The above is fairly trivial, but using carriage returns and indentation, it can be made much easier to read:


if (bCondition)
     someFunction(TRUE);
else
     someFunction(FALSE);

It is generally accepted that after placing a semicolon at the end of the line, one should also insert a carriage return (the [ENTER] key). This is not required, but not using carriage returns can quickly result in hard to maintain code. You can also use a carriage return to break up a long function call, or clarify nested function calls.


action aConvo = ActionStartConversation(GetObjectByTag("SOME_TAG"), "Hey you!", FALSE);

becomes


action aConvo = ActionStartConversation(
     GetObjectByTag("SOME_TAG"),
     "Hey you!",
     FALSE
);




 author: Charles Feduke