Skip to content

Instantly share code, notes, and snippets.

@The-Quill
Last active February 9, 2016 01:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save The-Quill/3e84df546ececebd02c7 to your computer and use it in GitHub Desktop.
Save The-Quill/3e84df546ececebd02c7 to your computer and use it in GitHub Desktop.

#Whitespace

You should have whitespace around your operators:

xcoord=avenue;
for(int i=0;i<count;i++)

#Magic Numbers

In your code, magic numbers are numbers that are unexplained and simply left as is:

public void turnLeft()
{
	turnLeft(1);
}
public void turnRight()
{
	turnLeft(3);
}
public void turnAround()
{
	turnLeft(2);
}

You should move these magic numbers to another variable, so their purpose is more easily understandable.


#turnLeft:

This variable name could probably use better terminology than that.


#goTo:

You will incur the wrath of many programmers using this a method name, use a different name like jumpToCoordinate


#cases:

You should be using camelcase for variable names:

int xdiff=xdest-xcoord;
int ydiff=ydest-ycoord;

Not to mention they could use a refactor, it's a few chararacters for readability and maintainability:

xDifference, xDestination, xCoordinate, see? much better

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment