GML Blog‎ > ‎

Dos and Don'ts

The following may be obvious to more experienced programmers, but trust me, even though some of this is ridiculous, I have seen people do it.


(Assuming goose[x,x] has been already created and populated by all 0s)
Don't do this:
for (i = 0;i < 100;i += 1)
{
    goose[0,i]= 12

    if gooseIsRunning = 1 then goose[0,88]=3
}
for (i = 0;i < 100;i+ = 1)
{
    if goose[0,i] +
goose[0,88] = 15 then goose[0,i] = 10
}


Instead do this:
if gooseIsRunning = 1
{
    for (i = 0;i < 100;i += 1)
    {
        goose[0,i]= 12
    }

       goose[0,88] = 3
}
else
{
    for (i = 0;i < 100;i += 1)
    {
        goose[0,i]= 10
    }

}


Don't do this:
if jack = 1 then jill = 1
if jack = 2 then jill = 4
if jack = 3 then jill = 9
if jack = 4 then jill = 16

if jack = 5 then jill = 28979

Instead do this:
if jack = 5 then jill = 28979 else if jack >=0 then jill = sqr(jack)

Affiliates