Clean Code

in the episode of variables, it’s better to teach out from the start clean code, ex. you are making a variable called xValue, well thats a bad naming, because we know x is a value, and it doesn’t really means anything, I would call it xVelocity, or xSpeed. it will also teach the new guys who learns programming to use meaningful names

1 Like

I thought like you, but after years of helping people I realized it’s a terrible idea to teach coding conventions to beginners because it can limit them way too much, for instance, beginners tend to create a lot of circular dependencies, which is something experience coders avoid like the plague, but for a beginner that has very few tools on his belt it’s actually ok to do that, It’s better to let them make a mess on their own and teach them little by little.

The argument would be that naming conventions wouldn’t affect negatively, but I disagree, a beginner will spend way more time figuring out a name because naming is quite hard, so you don’t want to deviate their attention from coding because coding is already hard to learn, and I know, for some coding isn’t that hard, but you can’t design a course based on those people, you gotta think first on the people that will have a really hard time learning.

We also tend to think that we can make people avoid certain mistakes, in my experience, that’s wrong, that’s a terrible way of teaching because we learn from making mistakes, let people fall so they learn how to stand up. I remember when I first learned about the singleton patten, my code became the biggest sphagetti ever, I had managers in top of managers, all of them were singletons and all of them reference each other, it was a nightmare to debug, but I learned a lot from that.

If I remember correctly, Rick does says something about naming, it’s somewhat vague and kinda random but he plants the seed in the student, and for a beginners course I think that’s more than enough.

1 Like

Well when you put it that way, I tend to agree, but it would be still good to mention that other people would eventually need to read your code (especially if they are posting their code for help) and it would be hard to read it, so a mention about it would be good I think.

1 Like

Totally, and I would accompany that with a full video on how to ask something properly, I don’t know how many times, here in these forums and others like Stackoverflow, I’ve seen people asking really vague things, making the whole process incredibly tedious when the solution is super simple.

1 Like

Well, normally I’d agree with you, but in this case the variable in question is literally holding the value by which we want to change the x axis.

“xValue” is actually a perfectly good descriptive name for a value used to change the x axis. I guess you could name it “xChange” or something, but the point is that the x actually stands for x axis, not the usual generic x that we try to avoid in good coding practice.

Privacy & Terms