Message from JavaScript discussions

February 2018

— Write your code as if you are standing in front of someone speaking to them

— 

I sometimes take this to an extreme and literally pretend I am reading some prepared speech, except it's my code I just wrote. At times I will get to a certain line and get long winded, run out of breath, and realize I crammed too much on one line

— That or I will get to a certain function, and while reading it back find my speech is bouncing all over the place, and then I know I have involved too many concerns in that function

Message permanent page

— Obviously we can make these determinations without doing all that... but it definitely helps make the code more smooth to understand and maintain sometimes

Message permanent page

— My CTO talks to his code all the time, sometimes loud and I have to wonder if he's talking to me or the code

Message permanent page

— Hahaha, oh gosh what does he say?

— I have to know

— Sometimes he reads it out, or explains calmly what it should do, and sometimes he just asks "why are you even working?"

Message permanent page

— That last one, too funny haha

— There is one style practice that helps me, and also meshes well with the whole speech thing... in a hoisted lang like JS you can do function declaration out of order of dependency, but if you always position them so that nothing above that line is dependent on it, your code structure becomes intuitive and you are always reading downwards. Never scrolling back up

Message permanent page

— 

function ayy() {
lmao();
}
function lmao() {
console.log("ayy lmao");
}

💀

— 

function lmao() {
console.log("ayy lmao");
}
function ayy() {
lmao();
}

👌