BullyWiiHacks
Welcome dear guest! Very Happy

To start posting and being part of the BWH community, you simply need to register an account or log into an existing one.

If you do not wish to register at all, that's fine but there will be more advertisements. :/

You can probably see and download most content provided for regular members even without an account.

Your contributions will be greatly appreciated though, give it a shot and register today! thumbsup

Join the forum, it's quick and easy

BullyWiiHacks
Welcome dear guest! Very Happy

To start posting and being part of the BWH community, you simply need to register an account or log into an existing one.

If you do not wish to register at all, that's fine but there will be more advertisements. :/

You can probably see and download most content provided for regular members even without an account.

Your contributions will be greatly appreciated though, give it a shot and register today! thumbsup
BullyWiiHacks
Would you like to react to this message? Create an account in a few clicks or log in to continue.
BullyWiiHacks

Gaming, Modding & Programming

Important reminders:

- Click *HERE* for advanced forum search or check out the text field below on the front page for Google before posting
- NO support via private message (use the forum)
- Write meaningful topic titles
Site Translation
Latest topics
» Dropped Out of College to Pursue Web Dev and Life Pursuits in General
Good Coding Style Empty5/16/2024, 8:25 am by Bully@WiiPlaza

» Bully Made It Into a BIG Video 400K Views
Good Coding Style Empty4/7/2024, 6:58 am by Bully@WiiPlaza

» Wii Play Tanks
Good Coding Style Empty3/24/2024, 2:46 pm by helpmeout

» [Bypass Paywalls] (Global) @magnolia1234 - GitLab
Good Coding Style Empty3/18/2024, 3:55 am by Seth@WiiPlaza

» [Download] Mary Shelley's Frankenhole
Good Coding Style Empty3/16/2024, 8:29 am by Seth@WiiPlaza

» Completely Custom Modded Controllers (Undetectable)
Good Coding Style Empty3/5/2024, 1:55 pm by Shadow@BWH

» (Zombies) Drink perks code?
Good Coding Style Empty3/5/2024, 1:24 pm by Shadow@BWH

» Die Rückkehr zu STEAM und WARFACE
Good Coding Style Empty3/2/2024, 3:54 am by Seth@WiiPlaza

» First person hand model change?
Good Coding Style Empty2/28/2024, 4:53 am by Ad3lamac611

» {RELEASE} Field Raider Firefox v1.72 by Seth@WiiPlaza
Good Coding Style Empty2/21/2024, 8:52 am by naxil

Search
 
 

Display results as :
 


Rechercher Advanced Search

May 2024
MonTueWedThuFriSatSun
  12345
6789101112
13141516171819
20212223242526
2728293031  

Calendar Calendar

Country Statistics
Free counters!

You are not connected. Please login or register

Good Coding Style

Go down  Message [Page 1 of 1]

1Important Good Coding Style 10/4/2014, 4:55 am

Bully@WiiPlaza

Bully@WiiPlaza
 
 

If you want to write good code, make sure to format your code by indenting code which is inside brackets. Also place your opening and closing brackets on a new line. Use the tab button to indent, NOT the space.

Good Coding Style Tab-Key-Word-Tutorials

Unfortunately, this forum doesn't support it but use it in code editors!

Also do NOT use formatter programs like Uncrustify, they mess up the code. Do it by hand!

Separate logical statements from each other like declarations, assignments and function calls.

Bad formatted code:
Code:
doStuff(){self iPrintLn("Hi");
variable = 0;
variable++;
anotherVariable = variable;}

Good formatted code:
Code:
doStuff()
{
 self iPrintLn("Hi");
 
 variable = 0;
 variable++;
 
 anotherVariable = variable;
}

Coding-wise, replace identical code with a function and use variables for dependencies. Do not write 1, 2, 3, 4, 5, ... instead use a variable and increment that. Also do not use possibly unclear statements if a better one exists.

Bad logical code:
Code:
myArray = [];

myArray[0] = 0;
self iPrintLn(myArray[0]);
myArray[1] = 1;
doMoreStuff(myArray[1]);
myArray[2] = 2;
doMoreStuff(myArray[2]);

for(;;)
 doEndlessly();

Good logical code:
Code:
myArray = [];

for(i = 0; i < 3; i++)
{
 myArray[i] = i;
 print(i);
}

while(1)
{
 doEndlessly();
}

print(index)
{
 self iPrintLn(myArray[index]);
}
Surely the good logical codes require more knowledge and experience but it is excellent to maintain as opposed to changing a huge and weird mess. Do not confuse with short codes though, readability is more important. Do not exaggerate with refactoring either, find the right balance. Never copy and paste same code into your file. Make a function and call it when needed.

Thanks for reading and I hope it helped you write some better code. Wink


_________________
Good Coding Style YBjg74I

Back to top  Message [Page 1 of 1]

Permissions in this forum:
You cannot reply to topics in this forum