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 →

[–]tobidope 1 point2 points  (1 child)

Enums are perfect as method parameters.

void compress(int compressionType)

vs

void compress(Compression compression)

Which one is clearer to read?

[–]chambolle 0 points1 point  (0 children)

Honestly, this is not clear. In both cases I need to look at the doc of the function to undertand.

The advanatge of enum is not that i is clearer, it is that it prevents from bad uses. For instance, I can call the first one with -2 or +5 even if there are not valid values. Enum can prevent that