I used to always name a list followed by the word List, but then I was asked by other coworkers not to. If you have:
List<GridPosition> validGridPositionList = new List<GridPosition>();
And then at some point the List is changed to a LinkedList, HashSet or something else, now your name is incorrect and you have to change the name of your variable. However if instead of List you just use the plural:
List<GridPosition> validGridPositions = new List<GridPosition>();
Now it can be changed without having to refactor the name (which believe me, will get missed )
I’d also like to point out that Visual Studio & Rider both suggest to use implicitly typed lists like:
var validGridPositions = new List<GridPosition>(); (Rider)
List<GridPosition> validGridPositions = new(); (Visual Studio)
Total preference, but I see most people implicitly type their lists. (mostly because they’re lazy like me and don’t want to type it twice). But again, if you change from a list of strings to a list of floats, you have to change it in two places.
Thanks Code Monkey!
Julian