“In programming, the only standard is its syntax.”
There’s no standard on how a programmer write his program. It’s always a matter of how a programmer should know how he will solve the problem in his own style. The only thing that matters is that the program should behave the way it must be. Eventhough, there are things that a good programmer should practice. Let me show you this list.
Best Practices in Programming
1. Naming Conventions
This practice was always taught in College. If you are going a variable, name it in a way that it could be recognized easily.
Example:
intAge >> an integer that returns age
douSalary >> a double that returns salary
strAddress >> a string that returns an address
In this way, a programmer can easily recognize the use of variables and the data type they should return. Another thing is naming a method/ functions/ subroutines.
Most of the times, we used comments to define what our method/ function/ subroutine will do. Instead of doing this, why not give it a name where it’s purpose could be easily recognize?
Example:
addTwoIntegers()
convertDecimalToHex()
deleteAnyFile()
connectToDatabase()
startExe()
I believe that you already understood what these functions will do even I do not put a definition as comment beside them.
Honestly, I am often guilty for not using it. But, I am only guilty on short programs. But for working on a large project, I use that style. On my previous post How Important Is A Program’s Documentation, I explained how important the program’s documentation is. And by following this practice, the code will serve as the documentation itself.
2. Case Sensitivity
This practice is applicable if you plan to run your program on different platforms. By the way, some programming languages are case sensitive itself. I think, the best example I could give here is the Java language which has the capability of being executed on different platform as long as there is JVM.
When working with Java in Windows OS, intAge is the same as IntAge and intAGE. But your program will encounter errors if you run it on Linux.
So, the best practice is, always think it’s case sensitive.
3. Symbols
I mean, the brackets, curly braces, semicolons, etc. Though there are good IDE which already gave solutions with this problem, it’s better to practice it.
I will just use an example for languages that use semicolons because using brackets, curly braces, and parentheses are common sense.
printf (“Hello World!”);
How do you used to write that code? Of course, you will type printf first. Isn’t it? Most of the times, semicolon in the end was forgotten. So, my tip is, put the semicolon first everytime.
4. That’s all!
Again, those are not standard. They are the best practices. You may use them or not for your own purpose. Again, the important thing is that your program should run the way it must be.
I hope you’ve learned something.
Class Dismiss.
This reminds me of Turbo Pascal and C Lang. The variables and integers. Medyo iba lang talaga sa Web Programming at Web development.
Good post bro.
In my opinion “Naming Convention” is one of the most underrated practices for new programmers. They simply don’t care about naming conventions, that’s why when they land a job, they have a hard time collaborating with fellow programmers.
I remember one moment in my college days. When I saw my classmate’s code, I was like “What the hell is this?!”. He uses around 10 or more variables, and he uses only single letter variable names. So I was like, “What is letter S suppose to hold? How about letter E and letter R?!” and so on. I can’t imagine someone coding like that on a REAL project. So there, I hope new programmers will give more importance to naming convention. Just my 2 cents.
Anyway, Good Post! 🙂
Thanks for good input Karl. Students can never realize the use of good naming convention until the code messed up in their mind.
Cool Post! Thanks for sharing! 🙂
Thanks for dropping by and reading Pat. 🙂