- Feature Articles
- CodeSOD
- Error'd
-
Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
For those not completely up-to-date with modern development acromyns such as KISS, DRY and HATEOAS, CYA is the well known strategy of Covering Your Arse.
Admin
Why is
parse
avoid
function? It this a class method setting some fields, or are there other side effects?Also, that "some" scares me, it implies you have a mix of YYMM and MMYY with no way of knowing which is which.
Admin
Also, no checking of
scanf
return value, wonderful UB on invalid inputAdmin
Variable expiryDate could have two symbols 'dm' or 'md' in the beginning so there would be no guessing. Also, there should be parsing of production date which ought to be used to calculate when product expires. What horrors await there?
Edit Admin
"calculate when product expires." I'm sure someone somewhere has written a ternary that compares individual members of two arrays to determine that.
Admin
Well it would be rude to not allow the Nasal Demons to come out and play just once in a while right?
evil grin
Yazeran
Admin
I suppose (or hope?) that something happens with the year and month values in the part represented by the "//..."
For the second matter, I suppose that the format is inverted in "some" part of the program, but they know that this "some" part is executed before calling this parsing functions.
How many suppositions, for a simple cow... aren't they?
Admin
This may be important or not, depending on whether the "expiry date" comes from an user (that may enter it wrong by mistake or on purpose), or is known to be correct and meaningful.
Not checking the results (when you know the input is valid) may be important or not, depending on whether the function is run once in a while, or in a cycle of cycles of cycles...
As in many cases (not only in programming), the missing context doesn't help. :-/
Admin
I see this all the time in coding interviews. There's a sort of developer who, if code has a bug (even their code) they will never change the buggy code, but just add "fix" around it.