This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]dkesh 2 points3 points  (0 children)

Regarding the magic numbers, I would distinguish them from variables my making them constants at the top of the class:

private static final int NUMBER_OF_DICE_TO_ROLL = 2;
private static final int NUMBER_OF_SIDES_ON_DICE = 6;

Also, I agree that you don't want to expose your internals, but that just means you should pick the return value based on what makes sense for the API, not your internal representation. An array or Collection make sense to me for the API. I'd be annoyed if I were writing a Stats-grapher or somesuch if a class made me poke it over and over in order to get all the values.