Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Clean Coding - Common Sense (https://forums.graalonline.com/forums/showthread.php?t=73158)

xXziroXx 04-08-2007 07:58 PM

I, too, think that example A looks better then example B.

A: if (var == true) { .... }
B: if (var) { .... }

Rapidwolve 04-08-2007 09:36 PM

Quote:

Originally Posted by xXziroXx (Post 1298117)
I, too, think that example A looks better then example B.

A: if (var == true) { .... }
B: if (var) { .... }

Thats how I had it on my script first, I forgot why I changed it

cbk1994 04-10-2007 04:29 AM

Quote:

Originally Posted by xXziroXx (Post 1298117)
I, too, think that example A looks better then example B.

A: if (var == true) { .... }
B: if (var) { .... }

C:
PHP Code:

if ( var == true )
{
    ...


C seems better than both ^^

xXziroXx 04-10-2007 01:23 PM

Quote:

Originally Posted by cbkbud (Post 1298646)
C:
PHP Code:

if ( var == true )
{
    ...


C seems better than both ^^

No way! I only make new lines for brackets on functions. And I just dont like that way of spacing :cry:

JkWhoSaysNi 04-10-2007 04:07 PM

Me either. The spaces inside the ( brackets offend me too ;)

Heres how I do it:

PHP Code:

if (var) {
       ...


i guess if (var) has more meaning if you name your boolean variables as verbs as I tend to do e.g. if (finished)

xXziroXx 04-10-2007 05:36 PM

Quote:

Originally Posted by JkWhoSaysNi (Post 1298731)
Me either. The spaces inside the ( brackets offend me too ;)

Heres how I do it:

PHP Code:

if (var) {
       ...


i guess if (var) has more meaning if you name your boolean variables as verbs as I tend to do e.g. if (finished)

Same as me then, although I would do:

PHP Code:

if (var == true) {
       ...



Skyld 04-10-2007 05:43 PM

PHP Code:

if (var)
{
  
// ...


I don't see the point in putting var == true when that's already implied, and I prefer brackets on their own line. It improves spacing and clarity.

Crow 04-10-2007 06:21 PM

Quote:

Originally Posted by Skyld (Post 1298760)
PHP Code:

if (var)
{
  
// ...


I don't see the point in putting var == true when that's already implied, and I prefer brackets on their own line. It improves spacing and clarity.

Lines++ ;/

Skyld 04-10-2007 06:27 PM

Quote:

Originally Posted by Crow (Post 1298768)
Lines++ ;/

Doesn't really matter. The script will be folded into the same amount of bytecodes with new lines as it is with brackets on the same lines.

The fact is that it's clearer when I'm editing the script.

JkWhoSaysNi 04-10-2007 07:11 PM

That's not a fact it's entirely subjective :P

I think less lines is clearer. I think it's easier to see which statement a block belongs to when the opening bracket is on the same line.

xXziroXx 04-10-2007 08:02 PM

Quote:

Originally Posted by JkWhoSaysNi (Post 1298782)
That's not a fact it's entirely subjective :P

I think less lines is clearer. I think it's easier to see which statement a block belongs to when the opening bracket is on the same line.

Agreed.

Novo 04-10-2007 09:01 PM

PHP Code:

function onKilled()
  {
  var;
  } 

I r bestest in Teh World!

Skyld 04-11-2007 12:09 AM

Quote:

Originally Posted by JkWhoSaysNi (Post 1298782)
That's not a fact it's entirely subjective :P

Quote:

Originally Posted by Skyld
The fact is that it's clearer when I'm editing the script.

I.

Novo 04-11-2007 12:51 AM

Quote:

Originally Posted by Skyld (Post 1298907)
I.

I.

cbk1994 04-11-2007 01:05 AM

Quote:

Originally Posted by Novo (Post 1298945)
I.

I.
--
Less lines? Really.

PHP Code:

//#CLIENTSIDE
function onCreated() { dothis(); thendothis(); thenletthis "foo"thendosomethingelse(); timetomilkthecow();doOTHERSTUFF()} function doOTHERSTUFF() { noWAI(); } function noWAI() { player.chat "MUAHAHAHAHAHAHAH!"; } 

Whoah you're right, that's really neat and clean!


All times are GMT +2. The time now is 03:34 PM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.