You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Dan shows these codes and wishes everyone to read them in his own way.
Experienced programmers may have their own monologue, and no matter what it is, Dan wishes those who read this article will establish the correct mental model which will help them understand codes better and well.
Coding, Fast and Slow
We all have two systems —— fast and slow.
This “fast” system is good at pattern matching (necessary for survival!) and “gut reactions”. But it’s not good at planning.
This “slow” system is responsible for complex step-by-step reasoning. It lets us plan future events, engage in arguments, or follow mathematical proofs.
function duplicateSpreadsheet(original) {
if (original.hasPendingChanges) {
throw new Error('You need to save the file before you can duplicate it.');
}
let copy = {
created: Date.now(),
author: original.author,
cells: original.cells,
metadata: original.metadata,
};
copy.metadata.title = 'Copy of ' + original.metadata.title;
return copy;
}
You’ve probably noticed that:
This function duplicates a spreadsheet.
It throws an error if the original spreadsheet isn’t saved.
It prepends “Copy of” to the new spreadsheet’s title.
What you might not have noticed (great job if you did though!) is that this function also accidentally changes the title of the original spreadsheet.
Missing the bug is not a big deal but rebuild the correct mental model is important.
The text was updated successfully, but these errors were encountered:
01. Mental Models
What’s a Mental Model?
The answer is a being 0 and b being 10.
Dan shows these codes and wishes everyone to read them in his own way.
Experienced programmers may have their own monologue, and no matter what it is, Dan wishes those who read this article will establish the correct mental model which will help them understand codes better and well.
Coding, Fast and Slow
We all have two systems —— fast and slow.
This “fast” system is good at pattern matching (necessary for survival!) and “gut reactions”. But it’s not good at planning.
This “slow” system is responsible for complex step-by-step reasoning. It lets us plan future events, engage in arguments, or follow mathematical proofs.
You’ve probably noticed that:
What you might not have noticed (great job if you did though!) is that this function also accidentally changes the title of the original spreadsheet.
Missing the bug is not a big deal but rebuild the correct mental model is important.
The text was updated successfully, but these errors were encountered: