2 ms·
Just the other day I showed one of our junior devs how they could turn their 10 lines of somewhat slow and obfuscated code into a 3 arguably more readable lines
by throwaway2016a 9y ago
Just the other day I showed one of our junior devs how they could turn their 10 lines of somewhat slow and obfuscated code into a 3 arguably more readable lines using a bitwise operations. And this was a front-end webapp.
Then again, more readable is subjective and some devs might see "<<" and get thrown off.
- onion2k 9y agoA reasonable 'compromise' of 3 lines of code with 7 lines of comment to explain what it's doing would be my preference.
- throwaway2016a 9y agoOr... and just throwing this out there... developers can take responsibility to know what bitwise operators do the same as they know what "+" does. The three lines of code were: for ( ... ) { x = x << y } The developer was essential using an array of booleans to simulate a bitwise operator. It is very sad that devs these days need a comment to know what that does. Would we expect 7 lines of comments if it was: for ( ... ) { x = x + y; }
- onion2k 9y agodevelopers can take responsibility to know what bitwise operators do the same as they know what "+" does Yes but they won't. Pragmatically speaking adding a comment to explain a concept the next developer won't use very often means you won't need to answer their questions about it when they next need to modify that piece of code. That's a big win for you, and it means the other developer can carry on being productive.