Preferable coding style

by 19:45 0 comments
In coding there is ton of coding styles that can be true for the compiler, but it is not okay to switch between them all the time, when you come back to your code it is not easy to understand what you did.

The most important that it should be easy for others to understand what are you doing.

So, this is the preferable coding style in my opinion - There is no one is the best for sure -

1- No recursion, Recursion eats the resources so if the code is going to be embedded with other codes there is no hope that the project will work.
2- No inner classes or multiple classes in the same file, Files should have the same name for the class, How can I find class when it is inner class or with other file? It is bad practice.
3- Tabs indentation, Tabs V.S. Spaces is a war but for me, I prefer tabs.
4- the braces should be as the following style

if (condition) {
    some code......

for (blabla) {
    some code.......

and so on

5- variables are camel case with first letter of the word lowercase. i.e. thisIsVariable
6- constants must be snake case and all uppercase letters. i.e. THIS_IS_CONSTANT
7- coding style is very complicated but the next three styles are good in my opinion

* comment line 1
* ........
* comment line n

// This is comment
This is code

This is Code // This is cimment

I hope this can help any one develop easy to read code, thanks.

Ammar Atef

Blog Creator

Always work and you will be happy, Writing code, designing system and learning some thing new, I call that real life, No matter what is the problem, humanity can solve it any way, Creative one who believes he is creative, Who really watch, think, try and success, World is watching us because we are engineers.


Post a Comment