Constant
Everything looks fine? Not really. In code below, we don't know what 1 means.
public void FireOnInvaders(Invader[] invaders)
{
foreach (Invader invader in invaders)
{
if (invader.IsActive && _location.InRangeOf(invader.Location, 1))
{
invader.decreaseHealth(1);
break;
}
}
}
We should make it more readable.
private const int _range = 1;
private const int _power = 1;
public void FireOnInvaders(Invader[] invaders)
{
foreach (Invader invader in invaders)
{
if (invader.IsActive && _location.InRangeOf(invader.Location, _range))
{
invader.decreaseHealth(_power);
break;
}
}
}