We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Except if you come back to this code at a later time (years) you have no idea what it does.
Programs were meant to be legible by people, code comments and whitespace are ignored by the compiler at build.
Regardless of if you write
print("Some line of text")
or
print("Some line of text")
the compiler won't care.
Also I've seen one liners take longer to finish than I have broken out code. Granted it was milliseconds, but in devland that's a long time, you start noticing the performance hit when all your methods take that long and you have hundreds of methods.
Also have to think of change.
You write a one liner to perform some task, leave no comments and make it hard to read. A year later your boss comes around and says hey found an issue in your code, line 5 error 4.
Well if line 5 has 10 things happening in one line, all you can hope for is that error 4 and it's not some random code generated by the compiler and its a well documented error code that means your Int didn't convert properly (maybe it is a nil value).
However, if it's line 5 error 4 and line 5 is a single task in 10 lines of code, you'll know exactly what's wrong with your code and you can immediately start testing with breakpoints to find out why it's broken.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Sherlock and Squares
You are viewing a single comment's thread. Return to all comments →
Except if you come back to this code at a later time (years) you have no idea what it does.
Programs were meant to be legible by people, code comments and whitespace are ignored by the compiler at build.
Regardless of if you write
or
the compiler won't care.
Also I've seen one liners take longer to finish than I have broken out code. Granted it was milliseconds, but in devland that's a long time, you start noticing the performance hit when all your methods take that long and you have hundreds of methods.
Also have to think of change.
You write a one liner to perform some task, leave no comments and make it hard to read. A year later your boss comes around and says hey found an issue in your code, line 5 error 4.
Well if line 5 has 10 things happening in one line, all you can hope for is that error 4 and it's not some random code generated by the compiler and its a well documented error code that means your Int didn't convert properly (maybe it is a nil value).
However, if it's line 5 error 4 and line 5 is a single task in 10 lines of code, you'll know exactly what's wrong with your code and you can immediately start testing with breakpoints to find out why it's broken.