The whole idea is really bad. This style defeats the whole idea of programming, no matter what language or platform.
You see, you use immediate constants "North", "West"… Imagine you mistype one. How can you support it? I can tell you this: if you're going to continue like this, it's better to give up programming at all. Try to see how good code is written.
Let's see.
enum Increment{ Down = -1, None = 0, Up = 1, };
struct Direction {
public Increment Vertical, Horizontal;
}
struct DirectionOnChart {
public DirectionOnChart(Increment eastWest, Increment northSouth) {
EastWest = eastWest;
NorthSouth = northSouth;
}
public Increment EastWest, NorthSouth;
}
Now, you never need East, West, etc., never need switch.
Here how you move in some direction:
void Move(double step, DirectionOnChart direction) {
CurrentCoordinate.X = step * (int) direction.EastWest;
CurrectCoordinate.Y = step * (int) direction.NorthSouth;
}
Something like that. Simple, not manual code, no ad-hoc code, no immediate constant (they belong in resources, input files, at least a block of explicit constants).
Never repeat a piece of code or data.
Don't Repeat Yourself (D.R.Y.), see
http://en.wikipedia.org/wiki/Don't_repeat_yourself[
^].
Learn
anti-patterns well and hit your own hand when it reaches for a work described as an anti-pattern:
http://en.wikipedia.org/wiki/Anti-pattern[
^].
—SA