How do you manage long lines of code?
I usually tend to split a long line early. I once read a study about UX and form reading on Smashing Mag, and they wrote that one should write input labels aove the input, not beside it, because a human can read faster from top to bottom. I tried it and it's true - for me at least. So I end up with stuff, like
doABarrelRoll()
.catch(displayErr)
.then(plane => plane
.doNotCrash()
.catch(displayErr)
.then(() => plane
.land()
.catch(displayErr)
.then(displaySuccess)
)
)
;
// or
this
.document
.querySelector('.js-foo')
.innerText
= this
.getUsers()
.map(u => u.name.trim())
.find(u => u.role === 'admin')
.email
;
How do you not get confused having thousands of line codes
Simple. I do not have file with thousands of lines of code. I modularize my code and put each module into its own file - sometimes even a single method with all its specific helper functions, if the file gets too long. Then its a simple search on the filesystem for a file with a specific name. Check out my architecture for extremely big modules :)