Importance of labeling in computer programming

in #computer7 years ago

There are a million reasons why you want to make sure you label each variable properly. The number 1 reason is because it’s easier to read and the importance of readability is also efficiency. The more you dive into computer programming you’ll learn the term DRY. Dry is an acronym for don’t repeat yourself. As a beginning programmer you’ll probably see this and know exactly where in your code that it repeats. This is where labeling comes in handy. Labeling is good practice for making sure your code is readable. Lets take a look at an example.

Screen Shot 2017-08-21 at 10.26.26 PM.png

You can see here that labeling plays a big part in understanding what the function is supposed to do. Clearly the variable randomword isn’t a random word. It’s a integral part of the sentence. We can get more in depth on what each word in the sentence does but that is for a later time. We all know that “The” is an article, “cat” is a noun, etc, etc but the point is that they are important for what makes a sentence a sentence. This same rule applies to most facets of programming. In order to really iterate what your thought process is for solving any coding problem is being able to make sure the label represents what your thought process is. It’s hard for most people to really put down on paper what it is that they are trying to convey so go with the gut instinct. Go with the variable name that is most appropriate for the variable name as well as the name of the function. In this example, badExample is actually a good indication of what I was trying to convey in this code but overall a bad name for the function.

Again I do want to iterate that I am not a professional coder by any means but with the amount of hours I have put into learning how to program, I can’t say that i’m the worst one either. It takes time and dedication to really honing in on your craft. Just like how you wouldn’t want to start a job with little to no experience (given that it’s not an entry level job), you want to really make sure that everything you do is with a purpose. There is always a purpose. Whether it’s wanting financial security or even a high paying job, that should be reason enough to want to be good at something.

Sort:  

I started many years back in C and people used single char variable names and things get cryptic quick. It is only when you come back later on and have to figure what is going on.

I am a firm believer in correct naming and even rename older code variables to help make them more explicit.

To me good names are better then comments and can help people understand the intent of code :)

Coin Marketplace

STEEM 0.20
TRX 0.15
JST 0.029
BTC 63396.80
ETH 2615.51
USDT 1.00
SBD 2.86