5 ms·
The whole problem could have been avoided if the agnostic had just added a simple comment stating that the code intentionally only handles strings of 3 or 4 dig
by jallardice 13y ago
The whole problem could have been avoided if the agnostic had just added a simple comment stating that the code intentionally only handles strings of 3 or 4 digits.
- anuragramdasan 13y agoI really doubt that was the point of the essay. I have seen many a times where different programmer rewrite the entire system and it is not for the lack of proper documentation.
- boyter 13y agoThey did. The unit tests covered that piece of functionality. The real issue with the story being why didn't any other the other dev's run the unit tests after making the change?
- chris_wot 13y agoMore fundamentally - why did they change the code in the first place?
- Grue3 13y agoBecause it was shitty code?
- vinceguidry 13y agoThe only thing shitty about it was that it didn't adequately explain the problem it was solving. However, that isn't apparent by looking at the code, the only way we could know that is either by reading/running the tests or asking the original developer. There would be no reason to rewrite until you had a reason.
- chris_wot 13y agoExcept it wasn't.
- qznc 13y agoAs far as I see, the behavior of the function is undefined for non-zip strings. There is no 'if digits.size < 3 or digits.size > 5 raise "invalid zip code"' or 'assert(digits.size <= 5 and digits.size >= 3, "invalid zip code")'. I prefer code to comment in this case. ;)