3 ms·
> Both are inferior to "$ymd". I half-prefer `$currentDate` but then it doesn't really contain the essential "it's a YMD string" information. `$currentYMD` wou
by zimpenfish 9y ago
> Both are inferior to "$ymd".
I half-prefer `$currentDate` but then it doesn't really contain the essential "it's a YMD string" information. `$currentYMD` would be better than all of the above, IMO.
All of which assumes you religiously stick to "`...YMD` means a 'Y-M-D' formatted string" and "`...Date` means a date object", mind, otherwise you might as well pick random strings.
- coldtea 9y ago>I half-prefer `$currentDate` but then it doesn't really contain the essential "it's a YMD string" information That information is not essential. If the date is later changed to also take hour/minute etc, it will still be currentDate but not YMD. Unless you need to work with the structure of the date, and not just pass it along, currentDate is better.
- zimpenfish 9y ago> That information is not essential. It is if you're passing it to something which expects to receive a YMD date. Also a `$currentDate` which also contains the time is borderline acceptable if specifically called out in comments / docs but I would still ding it in a review.
- coldtea 9y ago>It is if you're passing it to something which expects to receive a YMD date. You don't want to expose what kind of date string that something depends upon in your variable name. This way you you can change the internal implementation (what you pass and the function that received it) and not 1000 places where it's called.
- zimpenfish 9y ago> You don't want to expose what kind of date string that something depends upon in your variable name. Sure you do if you're a subscriber to Hungarian Notation. And if you're working in a loosely-typed language, it helps a lot to be able to track types through variable names.
- coldtea 9y ago>Sure you do if you're a subscriber to Hungarian Notation. Hungarian notation encodes types (and/or scope etc) -- not formatting details. Where would it stop if the latter was the case? >And if you're working in a loosely-typed language, it helps a lot to be able to track types through variable names. ymd is not a type though. str_currentDate is.
- dagw 9y agoThere are two 'schools' of Hungarian Notation, original Hungarian notation as described in the original paper, and Hungarian notation as used by the Windows team and later most MS Developers. Joel Spolsky has a pretty good blog post about them here: https://www.joelonsoftware.com/2005/05/11/making-wrong-code-look-wrong/ https://www.joelonsoftware.com/2005/05/11/making-wrong-code-...
- zimpenfish 9y ago> Hungarian notation encodes types (and/or scope etc) -- not formatting details That entirely depends on your interpretation of Hungarian - there are many. Plus "YMD" is easily valid as a type - imagine creating a struct with { y int; m int; d int; } and using that instead. > ymd is not a type though. Only because you have decided it isn't in this instance. There is no obstacle to it being a type.
- coldtea 9y agoAlso because types in PHP are specific things.
- deleted 9y ago[deleted]