Server Help

Bot Questions - Is this correct?

Quan Chi2 - Sun Sep 04, 2005 6:13 pm
Post subject: Is this correct?
I got flammed the last time for asking a question like this.. But is this correct? Whats wrong with it? It compiles...with 0 errors or warnings

Code: Show/Hide

         }
               if (c->check("fgpic1"))
               {
                  sendPrivate(p, "*objon 1");
               }
               else if (c->check("fgpicoff"))
               {
                  sendPrivate(p, "*objoff 1");
               }
               if (c->check("fgpic2"))
               {
                  sendPrivate(p, "*objon 2");
               }

Bak - Sun Sep 04, 2005 6:31 pm
Post subject:
perfect... now just put it in the right place icon_smile.gif
Quan Chi2 - Sun Sep 04, 2005 7:39 pm
Post subject:
lol
Mr Ekted - Sun Sep 04, 2005 8:25 pm
Post subject:
How about decent formatting (ie ekted style):

Code: Show/Hide
if (c->check("fgpic1"))
   sendPrivate(p, "*objon 1");
else if (c->check("fgpicoff"))
   sendPrivate(p, "*objoff 1");

if (c->check("fgpic2"))
   sendPrivate(p, "*objon 2");

CypherJF - Sun Sep 04, 2005 9:02 pm
Post subject:
That's just nevermind anyways.
Donkano - Sun Sep 04, 2005 11:04 pm
Post subject:
Mr Ekted wrote:
How about decent formatting (ie ekted style):

Code: Show/Hide
if (c->check("fgpic1"))
   sendPrivate(p, "*objon 1");
else if (c->check("fgpicoff"))
   sendPrivate(p, "*objoff 1");

if (c->check("fgpic2"))
   sendPrivate(p, "*objon 2");


Ick. That is harder to read through than with the { and }. Besides, it isn't much of a size change.

Here is how I would do it:

Code: Show/Hide

if (c->check("fgpic1")) {
   sendPrivate(p, "*objon 1");
   }
else if (c->check("fgpicoff")) {
   sendPrivate(p, "*objoff 1");
   }

if (c->check("fgpic2")) {
   sendPrivate(p, "*objon 2");
   }

Mr Ekted - Sun Sep 04, 2005 11:24 pm
Post subject:
Your way is gay. My way is perfect. icon_smile.gif
Assassin2684 - Sun Sep 04, 2005 11:55 pm
Post subject:
I dont know, i kinda like baks way but then agin i like everythign neat. So my code is always perfect icon_surprised.gif
Donkano - Mon Sep 05, 2005 12:16 am
Post subject:
Mr Ekted wrote:
Your way is gay. My way is perfect. icon_smile.gif


In your own little world I bet it is. But to others around you (like myself and Bak) it isn't.
Bak - Mon Sep 05, 2005 1:02 am
Post subject:
I usually use Quan's way for multi line braces and Ekted's way for single line braces (or lack of them). Although I'd probably put an empy line before that final 'if' or change it to an 'else if'. At this point it's whatever feels right.
Mr Ekted - Mon Sep 05, 2005 3:35 am
Post subject:
Donkano wrote:
In your own little world I bet it is. But to others around you (like myself and Bak) it isn't.


Don't quit your day jobs if you are going to code like retards.
Cerium - Mon Sep 05, 2005 4:40 am
Post subject:
Ish. Youre all wrong:

Code: Show/Hide

if (c->check("fgpic1")) {
   sendPrivate(p, "*objon 1");
} else if (c->check("fgpicoff")) {
   sendPrivate(p, "*objoff 1");
}

if (c->check("fgpic2")) { sendPrivate(p, "*objon 2"); }

Maverick - Mon Sep 05, 2005 5:40 am
Post subject:
I would do it like Cerium but its more or less a coder's etiquette to code without brackets when there is only one line to be executed after an if() statement.
Mr Ekted - Mon Sep 05, 2005 5:59 am
Post subject:
It's a question of readability. Less is more. Adding braces that are redundant is bad. Adding braces at the end or the beginning of a statement is the worst place for them. When you make a list of items, do you do this?:

Here's my intro text: List item 1
List item 2
List item 3
List item 4. Here's the summary text.

No! You do this:

Here's my intro text:

Here's the summary text.

Everything that is part of the list is indented, even the numbers or the bullets. Likewise in code:

Code: Show/Hide
if (...)
   single-line-statement;
else
   {
   multi;
   line;
   statement;
   }


Every statement at the same level lines up. All start/end braces at the same level line up. Most people code like they do because it's the way they were taught, not what makes sense. It's just like religion. People are sheep.
Smong - Mon Sep 05, 2005 6:26 am
Post subject:
I prefer opening and closing braces to be on the same level so I can read the code quickly. Although I sometimes shove everything on one line if it's a short java accessor/mutator or small try/catch block (could be 8 lines otherwise).
Maverick - Mon Sep 05, 2005 8:27 am
Post subject:
Mr Ekted wrote:
Most people code like they do because it's the way they were taught, not what makes sense. It's just like religion. People are sheep.

Agreed..


Donkano - Mon Sep 05, 2005 9:56 am
Post subject:
The way I posted is the way I would go about it if it was a big script, if it was a small script (less than 60 lines) I would go like this:

Code: Show/Hide

if (c->check("fgpic1"))
{
  sendPrivate(p, "*objon 1");
}
else if (c->check("fgpicoff"))
{
  sendPrivate(p, "*objoff 1");
}

if (c->check("fgpic2"))
{
  sendPrivate(p, "*objon 2");
}


Everything lines up and it is neat. Brackets get a 1 space indent and the content in it gets a 2 space indent.




Edit:
And it isn't showing up the 1st spaces. icon_sad.gif
Cyan~Fire - Mon Sep 05, 2005 10:29 am
Post subject:
Ekted's way is obviously the way to go. Everybody gives so much weight to spacing everything out these days, it's retarded. Yes, I know really spaced out code is easier to skim, but if each block is well-commented, then there's no reason to skim the code.
Bak - Mon Sep 05, 2005 11:04 am
Post subject:
so when you do a function, the braces start indented rather than against the left border?
D1st0rt - Mon Sep 05, 2005 1:31 pm
Post subject:
I'm going to have to agree with Ekted here, and cite his style specifications, which I agree with about 95%:


CypherJF - Mon Sep 05, 2005 1:33 pm
Post subject:
interesting; i agree with most of that, 'cept the method/function body not being indented.
D1st0rt - Mon Sep 05, 2005 1:35 pm
Post subject:
Thats the part I don't agree with him on, I like to indent too
CypherJF - Mon Sep 05, 2005 1:46 pm
Post subject:
It's really non-sense as I stated earlier. Most IDEs provide the templated formatting. If not, you can find a lot of free code formatters/cleaners. We discussed in the Wisconsin Java Group, how it's much more efficient for a programmer to program his/her own style, run a cleaner/formatter to company standard, and then commit it. He did put the caveat that one should not run "diff" without formatting the code first icon_wink.gif.
Mr Ekted - Mon Sep 05, 2005 2:23 pm
Post subject:
CypherJF wrote:
interesting; i agree with most of that, 'cept the method/function body not being indented.


You are correct Cyph; my function indenting is inconsistent with my general rules. It's simply because almost all the code in a file is lines of a function, and that would basically make the entire file indented. So I break my own rules for that one case.

Do we want to have the tabs/notabs debate as well? icon_smile.gif
CypherJF - Mon Sep 05, 2005 3:33 pm
Post subject:
NoOo.. lol. Seek post #46669.
Quan Chi2 - Mon Sep 05, 2005 5:56 pm
Post subject:
JESUS .... lol im gone for 1 night and i see all of these replies lol... Cool.. I didnt know you could take out the braces icon_smile.gif lol
All times are -5 GMT
View topic
Powered by phpBB 2.0 .0.11 © 2001 phpBB Group