Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I am using a lot of DateTimes in my application. Now I usually name it like Star

ID: 644842 • Letter: I

Question

I am using a lot of DateTimes in my application. Now I usually name it like StartDateTime, EndDateTime, etc, to imply there is also a time involved.

I am getting a bit tired of this (it is tiresome to read), and most of the time it is quite logical there is a time compartment to it anyway.

Now I'm thinking about ditching StartDateTime in favor of the shorter StartDate, despite that there is also a time part included.

Question

What is better: easier to read vs being more explicit about that there is a time included?

(ps: I guess this has a lot to do with C# not having separate objects for Date and DateTime, so that's where the need for Hungarian comes from)

Explanation / Answer

I would generally expect DateTime objects, so I would go with Start and End if they were datetimes and allow people who are in doubt to check the type definition, intellisense or documents.

It seems logical to prefer the more specific StartDate and EndDate for cases where you have only a date, which is more likely to be a special case.

As a general rule, I prefer not to include the type in my variable names unless it is going to behave in an unexpected way. Where possible I try to find ways to avoid variables that behave in unexpected ways.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote