Coders Lounge

Would you like to react to this message? Create an account in a few clicks or log in to continue.

For all of your programming needs and wants.


+4
dixee
Vivi_IX
Tirade
SoulRed12
8 posters

    Programming style

    SoulRed12
    SoulRed12
    Moderator
    Moderator


    Posts : 129
    Join date : 2009-05-08
    Age : 34
    Location : West-coast USA

    Programming style Empty Programming style

    Post by SoulRed12 11/3/2009, 3:44 pm

    What's your programming style?

    i.e., describe how you format your code. Do you comment a lot, not enough, indent using two spaces or the tab key, put curly braces on their own line, etc.

    When I program, I kind of mix and match...I'll put curly braces on their own line, for example, except when I'm getting impatient and I just stack all the statements inside the condition/loop/whatever on one line and surround them with the braces on the same line. Also makes it look neater IMO when you have multiple statements inside both parts of an if/else construction. For example,

    Code:
    if (this)
    {
      Do this
      Do that
    }

    if (that) {Do this; do that;}
    else {Do something; do another thing;}
    Tirade
    Tirade
    Stranger
    Stranger


    Posts : 22
    Join date : 2009-10-29

    Programming style Empty Re: Programming style

    Post by Tirade 11/3/2009, 7:42 pm

    My style is alot like yours, but I often forget to use semicolons.
    Vivi_IX
    Vivi_IX
    Stranger
    Stranger


    Posts : 38
    Join date : 2009-11-03
    Age : 34
    Location : USA: Painesville, Ohio

    Programming style Empty Re: Programming style

    Post by Vivi_IX 11/3/2009, 11:17 pm

    I could never bring myself to puting the actions on the same line of a condition. There's nothing wronge with it, it just dosn't seem right to me though. I always put semi-collens after action. I tab to indent. If I know what I am doing I don't really comment, but if I am just learning something difficult I'll comment the hell out of it!

    Code:

    //Some sort of greeting message
    draw_set_color(c_white);
    draw_set_alpha(1.0);

    draw_text(5,5,"Hello everyone");

    if reputation < reputation.other
    {show_message("You are my superior.");}
    else
    {
    show_message("I'm cooler than you :P");
    reputation.other -= 10;
    }
    dixee
    dixee
    Moderator
    Moderator


    Posts : 138
    Join date : 2009-10-26
    Age : 33
    Location : Orange County

    Programming style Empty Re: Programming style

    Post by dixee 11/6/2009, 2:50 am

    I don't comment a whole lot. Only when I have long scripts and it helps break it up (for instance, all the different attributes of player control get a label in the character's step event).

    Something like this:

    // I don't like to use '/*' and '*/' for comments

    if keyboard_check_pressed(vk_up) and pos==0 {
    __vspd=-8;
    __pos=1;
    } else if keyboard_check_pressed(vk_up) and pos==1 {
    __pos=2;
    __vspd=-6;
    __if place_meeting(x,y-1,obj_wall) {
    ____vspd=8;
    __}
    }


    Last edited by dixee on 11/10/2009, 4:32 pm; edited 1 time in total
    Mars
    Mars
    New Member
    New Member


    Posts : 60
    Join date : 2009-11-08
    Age : 36
    Location : Alaska

    Programming style Empty Re: Programming style

    Post by Mars 11/10/2009, 12:15 pm

    I'm awesome, I use drag and drop.
    Cool
    dixee
    dixee
    Moderator
    Moderator


    Posts : 138
    Join date : 2009-10-26
    Age : 33
    Location : Orange County

    Programming style Empty Re: Programming style

    Post by dixee 11/10/2009, 4:31 pm

    Mars001 wrote:I'm awesome, I use drag and drop.
    Cool
    Programming style Mah_Boi_is_HD_by_HWO
    Kt395
    Kt395
    New Member
    New Member


    Posts : 91
    Join date : 2009-11-03
    Location : US of A, Kansas to be more precise

    Programming style Empty Re: Programming style

    Post by Kt395 1/9/2010, 6:31 pm

    I use D&D oh yeah!
    ProgrammingLinguist
    ProgrammingLinguist
    Stranger
    Stranger


    Posts : 49
    Join date : 2010-01-06
    Location : LA

    Programming style Empty Re: Programming style

    Post by ProgrammingLinguist 1/9/2010, 10:22 pm

    hardly ever use if statements. i just go ahead and shove it all in a switch.

    no comments

    indent with tab

    indent EVERYTHING CLEARLY.

    lots of braces

    practice perfect coding format. Razz
    Whitepath
    Whitepath
    New Member
    New Member


    Posts : 109
    Join date : 2009-10-26

    Programming style Empty Re: Programming style

    Post by Whitepath 1/10/2010, 1:49 pm

    ProgrammingLinguist wrote:hardly ever use if statements. i just go ahead and shove it all in a switch.

    no comments

    indent with tab

    indent EVERYTHING CLEARLY.

    lots of braces

    practice perfect coding format. Razz

    But you dont use GML. "if" statements is just one of those things you have to use. Its not like its a pain any way =P
    ProgrammingLinguist
    ProgrammingLinguist
    Stranger
    Stranger


    Posts : 49
    Join date : 2010-01-06
    Location : LA

    Programming style Empty Re: Programming style

    Post by ProgrammingLinguist 1/10/2010, 2:37 pm

    yeah if statements are useful. but at the moment i'm coding a txt based rpg game. it uses switches for choosing options. so .... yeah it's just a lot easier to use switches in situations like mine rather than if statements

    i should have specified that i was in game-thought-mode. so i wasn't thinking about general coding :/

    Sponsored content


    Programming style Empty Re: Programming style

    Post by Sponsored content


      Current date/time is 11/21/2024, 8:26 am