Server Help Forum Index Server Help
Community forums for Subgame, ASSS, and bots
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   StatisticsStatistics   RegisterRegister 
 ProfileProfile   Login to check your private messagesLogin to check your private messages   LoginLogin (SSL) 

Server Help | ASSS Wiki (0) | Shanky.com
Is this correct?
Goto page 1, 2  Next
 
Post new topic   Reply to topic Printable version
 View previous topic  duel plugin by mav Post :: Post D1stort and I are getting Married!  View next topic  
Author Message
Quan Chi2
Member of "Sexy Teenagers that Code" Group
Member of


Age:34
Gender:Gender:Male
Joined: Mar 25 2005
Posts: 860
Location: NYC
Offline

PostPosted: Sun Sep 04, 2005 6:13 pm    Post subject: Is this correct? Reply to topic Reply with quote

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");
               }
Back to top
View users profile Send private message Add User to Ignore List Send email Visit posters website AIM Address Yahoo Messenger MSN Messenger
Bak
?ls -s
0 in


Age:26
Gender:Gender:Male
Joined: Jun 11 2004
Posts: 1826
Location: USA
Offline

PostPosted: Sun Sep 04, 2005 6:31 pm    Post subject: Reply to topic Reply with quote

perfect... now just put it in the right place icon_smile.gif
_________________
SubSpace Discretion: A Third Generation SubSpace Client
Back to top
View users profile Send private message Add User to Ignore List AIM Address
Quan Chi2
Member of "Sexy Teenagers that Code" Group
Member of


Age:34
Gender:Gender:Male
Joined: Mar 25 2005
Posts: 860
Location: NYC
Offline

PostPosted: Sun Sep 04, 2005 7:39 pm    Post subject: Reply to topic Reply with quote

lol
Back to top
View users profile Send private message Add User to Ignore List Send email Visit posters website AIM Address Yahoo Messenger MSN Messenger
Mr Ekted
Movie Geek


Gender:Gender:Male
Joined: Feb 09 2004
Posts: 1379
Offline

PostPosted: Sun Sep 04, 2005 8:25 pm    Post subject: Reply to topic Reply with quote

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");

_________________
4,691 irradiated haggis!
Back to top
View users profile Send private message Add User to Ignore List
CypherJF
I gargle nitroglycerin


Gender:Gender:Male
Joined: Aug 14 2003
Posts: 2582
Location: USA
Offline

PostPosted: Sun Sep 04, 2005 9:02 pm    Post subject: Reply to topic Reply with quote

That's just nevermind anyways.
_________________
Performance is often the art of cheating carefully. - James Gosling
Back to top
View users profile Send private message Add User to Ignore List
Donkano
Server Help Squatter


Gender:Gender:Male
Joined: Jul 02 2003
Posts: 763
Offline

PostPosted: Sun Sep 04, 2005 11:04 pm    Post subject: Reply to topic Reply with quote

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");
   }
Back to top
View users profile Send private message Add User to Ignore List
Mr Ekted
Movie Geek


Gender:Gender:Male
Joined: Feb 09 2004
Posts: 1379
Offline

PostPosted: Sun Sep 04, 2005 11:24 pm    Post subject: Reply to topic Reply with quote

Your way is gay. My way is perfect. icon_smile.gif
Back to top
View users profile Send private message Add User to Ignore List
Assassin2684
Server Help Squatter


Age:34
Gender:Not sure
Joined: Jul 27 2004
Posts: 990
Location: Florida
Offline

PostPosted: Sun Sep 04, 2005 11:55 pm    Post subject: Reply to topic Reply with quote

I dont know, i kinda like baks way but then agin i like everythign neat. So my code is always perfect icon_surprised.gif
Back to top
View users profile Send private message Add User to Ignore List AIM Address
Donkano
Server Help Squatter


Gender:Gender:Male
Joined: Jul 02 2003
Posts: 763
Offline

PostPosted: Mon Sep 05, 2005 12:16 am    Post subject: Reply to topic Reply with quote

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.
Back to top
View users profile Send private message Add User to Ignore List
Bak
?ls -s
0 in


Age:26
Gender:Gender:Male
Joined: Jun 11 2004
Posts: 1826
Location: USA
Offline

PostPosted: Mon Sep 05, 2005 1:02 am    Post subject: Reply to topic Reply with quote

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.
Back to top
View users profile Send private message Add User to Ignore List AIM Address
Mr Ekted
Movie Geek


Gender:Gender:Male
Joined: Feb 09 2004
Posts: 1379
Offline

PostPosted: Mon Sep 05, 2005 3:35 am    Post subject: Reply to topic Reply with quote

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.
Back to top
View users profile Send private message Add User to Ignore List
Cerium
Server Help Squatter


Age:42
Gender:Gender:Male
Joined: Mar 05 2005
Posts: 807
Location: I will stab you.
Offline

PostPosted: Mon Sep 05, 2005 4:40 am    Post subject: Reply to topic Reply with quote

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"); }

_________________
There are 7 user(s) ignoring me right now.
Back to top
View users profile Send private message Add User to Ignore List AIM Address
Maverick
broken record


Age:40
Gender:Gender:Male
Joined: Feb 26 2005
Posts: 1521
Location: The Netherlands
Offline

PostPosted: Mon Sep 05, 2005 5:40 am    Post subject: Reply to topic Reply with quote

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.
_________________
Nickname: Maverick (I changed my name!)
TWCore developer | Subspace statistics
Back to top
View users profile Send private message Add User to Ignore List Visit posters website
Mr Ekted
Movie Geek


Gender:Gender:Male
Joined: Feb 09 2004
Posts: 1379
Offline

PostPosted: Mon Sep 05, 2005 5:59 am    Post subject: Reply to topic Reply with quote

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:
    List item 1
    List item 2
    List item 3
    List item 4

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.
Back to top
View users profile Send private message Add User to Ignore List
Smong
Server Help Squatter


Joined: 1043048991
Posts: 0x91E
Offline

PostPosted: Mon Sep 05, 2005 6:26 am    Post subject: Reply to topic Reply with quote

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).
Back to top
View users profile Send private message Add User to Ignore List Visit posters website MSN Messenger
Maverick
broken record


Age:40
Gender:Gender:Male
Joined: Feb 26 2005
Posts: 1521
Location: The Netherlands
Offline

PostPosted: Mon Sep 05, 2005 8:27 am    Post subject: Reply to topic Reply with quote

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..





Sheep_intro[1].gif - 7.82 KB
File downloaded or viewed 8 time(s)
Back to top
View users profile Send private message Add User to Ignore List Visit posters website
Donkano
Server Help Squatter


Gender:Gender:Male
Joined: Jul 02 2003
Posts: 763
Offline

PostPosted: Mon Sep 05, 2005 9:56 am    Post subject: Reply to topic Reply with quote

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
Back to top
View users profile Send private message Add User to Ignore List
Cyan~Fire
I'll count you!
I'll count you!


Age:37
Gender:Gender:Male
Joined: Jul 14 2003
Posts: 4608
Location: A Dream
Offline

PostPosted: Mon Sep 05, 2005 10:29 am    Post subject: Reply to topic Reply with quote

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.
_________________
This help is informational only. No representation is made or warranty given as to its content. User assumes all risk of use. Cyan~Fire assumes no responsibility for any loss or delay resulting from such use.
Wise men STILL seek Him.
Back to top
View users profile Send private message Add User to Ignore List Visit posters website
Bak
?ls -s
0 in


Age:26
Gender:Gender:Male
Joined: Jun 11 2004
Posts: 1826
Location: USA
Offline

PostPosted: Mon Sep 05, 2005 11:04 am    Post subject: Reply to topic Reply with quote

so when you do a function, the braces start indented rather than against the left border?
Back to top
View users profile Send private message Add User to Ignore List AIM Address
D1st0rt
Miss Directed Wannabe


Age:37
Gender:Gender:Male
Joined: Aug 31 2003
Posts: 2247
Location: Blacksburg, VA
Offline

PostPosted: Mon Sep 05, 2005 1:31 pm    Post subject: Reply to topic Reply with quote

I'm going to have to agree with Ekted here, and cite his style specifications, which I agree with about 95%:


_________________

Back to top
View users profile Send private message Add User to Ignore List Visit posters website
CypherJF
I gargle nitroglycerin


Gender:Gender:Male
Joined: Aug 14 2003
Posts: 2582
Location: USA
Offline

PostPosted: Mon Sep 05, 2005 1:33 pm    Post subject: Reply to topic Reply with quote

interesting; i agree with most of that, 'cept the method/function body not being indented.
Back to top
View users profile Send private message Add User to Ignore List
D1st0rt
Miss Directed Wannabe


Age:37
Gender:Gender:Male
Joined: Aug 31 2003
Posts: 2247
Location: Blacksburg, VA
Offline

PostPosted: Mon Sep 05, 2005 1:35 pm    Post subject: Reply to topic Reply with quote

Thats the part I don't agree with him on, I like to indent too
Back to top
View users profile Send private message Add User to Ignore List Visit posters website
CypherJF
I gargle nitroglycerin


Gender:Gender:Male
Joined: Aug 14 2003
Posts: 2582
Location: USA
Offline

PostPosted: Mon Sep 05, 2005 1:46 pm    Post subject: Reply to topic Reply with quote

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.
Back to top
View users profile Send private message Add User to Ignore List
Mr Ekted
Movie Geek


Gender:Gender:Male
Joined: Feb 09 2004
Posts: 1379
Offline

PostPosted: Mon Sep 05, 2005 2:23 pm    Post subject: Reply to topic Reply with quote

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
Back to top
View users profile Send private message Add User to Ignore List
CypherJF
I gargle nitroglycerin


Gender:Gender:Male
Joined: Aug 14 2003
Posts: 2582
Location: USA
Offline

PostPosted: Mon Sep 05, 2005 3:33 pm    Post subject: Reply to topic Reply with quote

NoOo.. lol. Seek post #46669.
Back to top
View users profile Send private message Add User to Ignore List
Display posts from previous:   
Post new topic   Reply to topic    Server Help Forum Index -> Bot Questions All times are GMT - 5 Hours
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum
View online users | View Statistics | View Ignored List


Software by php BB © php BB Group
Server Load: 58 page(s) served in previous 5 minutes.

phpBB Created this page in 0.607777 seconds : 52 queries executed (86.1%): GZIP compression disabled