4 ms·
Then why do I spend so much time fixing bugs in code where the concept was complicated to the nth degree so it could be written in five lines instead of ten? I
by rnernento 10y ago
Then why do I spend so much time fixing bugs in code where the concept was complicated to the nth degree so it could be written in five lines instead of ten?
I agree that fewer lines of code is better, unfortunately if you hold that concept in too high a regard it's easy to make a mess. Some programming challenges are complex and the complexity can't be avoided. Sometimes solving that problem in fewer lines of code makes the problem even more complex. Just because the complexity is moving from the code itself into the developers head doesn't NECESSARILY mean that it will be less prone to bugs.
- mordocai 10y agoThose 5 lines probably had 100s if not thousands of lines backing them. Maybe best to say 'fewer lines of code executed' as it doesn't really matter whether those lines are in a library or in your project, they still have a chance for bugs.
- rnernento 10y agoYou're missing the point, it's not about executed code it's about concepts and simplicity. Sometimes people work too hard to make two functions with slightly different objectives into a single complicated function. This can save lines of code since you aren't writing two similar functions. In general this is good practice but it's VERY common to take this too far, and it's very likely that the resulting complicated function will be MORE prone to bugs than the two simpler functions would have been.