- Good:
- C#: public bool IsOnDice(int possibleValue)
- JavaScript: isOnDice(possibleValue)
- Not so good:
- C#: public bool IsCrappedOut()
- JavaScript: isCrappedOut()
In my imagination isOnDice just tells you if the number handed in is between 2 and 12, HOWEVER the not
idempotent isCrappedOut I envision as bad:
- generates a sum of two separate random numbers between 1 and 6,
- sets state at a field for LastRoll with the value,
- returns false if the value is 2, 3, or 12,
- and true otherwise
If the logic in isCrappedOut is only called by one other method/function and it can just be tucked into that method/function, that might be better than having isCrappedOut standalone. Otherwise, it needs a better name, one that does not start with is.
No comments:
Post a Comment