![]() ![]() Do not use letters like x, y, a, or b as variable names unless there is a good reason (loop variables are an exception to this). It is a common misconception that you should hide your mess with comments. I have seen this type of code so many times. If a name requires a comment, then the name does not reveal its intent." – Clean Code "A name should tell you why it exists, what it does, and how it is used. If a name requires a comment, then you should take your time to rename that variable instead of writing a comment. ![]() How to Create Meaningful Namesĭo not use comments to explain why a variable is used. And I am sure most readers have faced the situation where you visit your code only a few months later and have a hard time understanding what you did before. It can take some time to find a good name but it will save you and your team even more time in the future. And, more importantly, they can give you more information about the variable, so someone else can understand its significance. ![]() There is a reason why we do not use memory addresses and have names instead: names are much easier to recall. How to Name Variables (and other things) "There are only two hard things in Computer Science: cache invalidation and naming things." – Phil Karlton It is a programming classic and I suggest you read the whole text when you have time. In this post, we will look at the most important principles to improve code quality and I will give you code examples for each of them. Writing clean, understandable, and maintainable code is a skill that is crucial for every developer to master. Good programmers write code that humans can understand." – Martin Fowler "Any fool can write code that a computer can understand. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |