Coding in text languages give you a lot of freedom to do whatever you want, but they are also a lot more difficult to read since they aren’t just code blocks arranged in different orders.
This is why it’s especially important to keep in line with a consistent way of writing code. Everyone writes their code in a slightly different style, and that style can change over time, but it’s always important that you keep all code in a single project looking the same.
All too many times people tend to write code like this:
function blue_Baird() {
var bird = new DrawBoard(10, 10)
setTimeout(function() {
for (let x = 0; x < 10; x++) { bird.point(x, x); }
}
bird.draw();
}
What can you understand from the code above? Not much. You may think the function draws a bird, but what does it actually do? Does it draw a bird, a line, and x? Who knows… we can’t easily understand it.
Let’s take a look at how we can make readable code.