4 ms·
Correctness (and any other kind of change in behaviour) is easier to achieve if things are simple. Changes are not necessarily easy or even possible to make sa
by martingxx 8y ago
Correctness (and any other kind of change in behaviour) is easier to achieve if things are simple.
Changes are not necessarily easy or even possible to make safely if things are correct but not simple.
"Simple" is a proxy for "can be changed safely" and so IMO is the most important quality to have.
- DannyB2 8y agoI think you do whatever it takes to achieve correctness. If simplicity helps achieve correctness, then great. But correctness is not always simple. Most people think there is a leap year every four years. They are wrong.
- ythn 8y agoThe simple thing to do then is to call an `isLeapYear` function that abstracts any complexity. Abstraction allows you to hide complexity and make it a simple, reusable part again.
- DannyB2 8y agoBut I could write a simpler (incorrect) leap year function than yours!
- ythn 8y agoYou missed the point of the article if you interpreted it as correctness being intentionally sacrificed for simplicity. Plus, a complete leap year implementation is already what I would consider simple and most standard libraries already have an implementation for it you can use directly.
- deleted 8y ago[deleted]
- rbonvall 8y agoI know a couple of guys that would probably implement isLeap by checking that the lower two bits of the year are not set, then boast about how fast it was, and finally, when told that the logic was incorrect, push back because the additional checks would make it "slower". In their minds, when things stop being simple, fast trumps correct.
- gkya 8y agoI don't think simple means discard if complex. It means using the simplest and most obvious tools (algorithms, libraries, &c) possible in order to achieve a correct enough software. So it does not mean discarding intricacies of timekeeping, but implementing it with the clearest, simplest use of abstractions and methods possible.
- pofilat 8y agoMy calculator watch worked perfectly for 50 years on that "wrong" assumption.
- adrianmonk 8y agoOne nuance is that some parts of correctness may be negotiable. If I'm writing a file backup program, it absolutely must back up all the files without leaving any out or corrupting the data. But let's say it has a feature that prints progress indicator percentages on the command line, ranging from 0% to 100%. Maybe under certain circumstances (like files added to a directory after the backup starts), it prints 102%. It's not what I had in mind, nor is it something I'd call correct. But if fixing it complicates the code a lot, maybe leaving it that way is the better choice. (This is a bit of a contrived example because you could just clip the value at 100, but you get the idea.)