lundi 2 février 2015

Should enumerated types by pluralized?


I'm trying to decide how to name my enums.


First I tried plural:



private enum Positions { LEFT, RIGHT, UP, DOWN }
private Positions pos;
// ...
public void setPosition(Positions newPosition) { pos = newPosition; }


that was fine in declaration but awkward later on. So I tried singular:



private enum Position { LEFT, RIGHT, UP, DOWN }
private Position pos;
// ...
public void setPosition(Position newPosition) { pos = newPosition; }


which sounds awkward in declaration but fine later on.


No matter which one of these I choose, it doesn't feel right. Is there a precedent to this? Perhaps a large organization's reasoning behind choosing one or another?





Aucun commentaire:

Enregistrer un commentaire