HOW TO WRITE CODE?

Posted by Alert Games on April 1, 2012, 12:06 p.m.

How do you write code?

A:

if (this==statement) {
code = 1;
     if (this==another) {
     moar = 2;
     }
}

B:

if (this == statement)
{
     code = 1;
     if (this == another)
     {
          moar = 2;
     }
}

C:

if (this == statement)
{
code = 1;
if (this == another)
{
moar = 2;
}
}

Notice I put semicolons after every assignment, because it is good practice.

I also put "==", even though this isnt required in game maker, its required in other languages. Probably because you can assign variables within statements in other languages.

Personally I code in A, but i think the most legible and widely used is B.

What would be cool is if there was an option in game maker to clean their code up to standards, for learning purposes.

In other news, YOYOgames is starting to go bankrupt. Which i find hallarious.

heres the link: yoyogames

Comments

Acid 12 years, 8 months ago

Those pre-bracket tabs make me want to hurt things.

Rob 12 years, 8 months ago

Quote:
Those pre-bracket tabs make me want to hurt things.

This.

firestormx 12 years, 8 months ago

Quote:
Quote:
Those pre-bracket tabs make me want to hurt things.

This.
This.

Alert Games 12 years, 8 months ago

Quote:
Quote:
Quote:
Those pre-bracket tabs make me want to hurt things.
This.
This.
This.

Zhiko 12 years, 8 months ago

I used to code similarly to C, but that always ended up as an ungodly mess so now I do B.

Moikle 12 years, 8 months ago

Quote:
Quote:
Quote:
Quote:
Those pre-bracket tabs make me want to hurt things.
This.
This.
This.
Thiswell, I only recently stopped doing it.

svf 12 years, 8 months ago

I would do B.

Alert Games 12 years, 8 months ago

As of recently I now do a mix of A and B like ludamad mentioned.

The reason why A was popular is because a lot of examples in GM were coded that way so I picked up on that. But now I indent after statements. It is easier to read.

JuurianChi 12 years, 8 months ago

A mixture of A and B usually happens when I write.

LAR Games 12 years, 8 months ago

*Walks in*

Oh, a programming discussion?

*Walks out*