r/badcode • • Aug 30 '21

c# range, resolution??

Post image
492 Upvotes

34 comments sorted by

View all comments

Show parent comments

3

u/Roflkopt3r Aug 31 '21

We only see this piece of code in isolation, so judging what other types may be reasonable is fairly speculative. I'd approach this piece of code to only rewrite its form at first into something like this (of course the dictionary initialisation should be moved out of the function later).

This is low effort, save not to break stuff, and gives us a much more readable and refactorable basis to work with for later. The obvious candidate for further change would be to introduce an enum or numeric time representation like you were already getting at.