What makes you a good programmer? Every person can write code or create a script then what’s the difference between a professional programmer and an ordinary coder. There are two types of codes; good code and the bad one. Good code is easier to understand by some other person and it is easily editable, considering all codes to be efficient in working. And a person who can write a clean and understandable code is a good programming professional.
Principles To Become A Good Programmer
Professionalism demands integrity and a principled approach to do every task. A professional developer has to follow some rules and regulations to write good code.
Keep it simple, stupid. Try to keep your code as simple as possible. Complex code has more bugs. And nobody likes to fix bugs in a complex code. Even most systems work best if their code is kept simple. Because the simplicity of your code allows other programmers to touch it for editing. If your code is not understandable the other person would have to waste a plenty of time first to get the functionality of your code and editing or bug fixation would take a whole level of effort.
Don’t repeat yourself. Avoid creating redundancy while coding as it makes debugging easier. Duplication of data, logic or code only makes the program lengthy and complicated. For a clean and easy-to-modify code DRY principle must be followed.
The opposite of the DRY principle is the WET principle that means; waste everyone’s time, or to write everything twice. This principle says, okay keep on creating redundancy in your code and reduce the efficiency of the whole working team.
You aren’t gonna need it. If you are adding a part on your own while developing a software, it can create scope creep first, secondly it will cause wastage of time and space. If you don’t need a part of code immediately, don’t add it. Some programmers keep on adding the codes that are irrelevant and belong to some other feature that is not required at the moment. It just wastes time and resources. Don’t do it!
Object oriented programming becomes crucial when there comes a point of scalable, reusable, maintainable and flexible code. While using OOP the programmer should have the knowledge of SOLID principle which is the acronym of five more principles:
- Single Responsibility Principle
- Open/Closed Principle
- Liskov’s Substitution Principle
- Interface Segregation Principle
- Dependency Inversion Principle
For a better understanding of these five principles you can read this blog.
SoC stands for separation of concern principle. This principle promotes the partition of complex application in separate categories where a single concern would be dealt. This assists the programmers to debug the code with great ease.
While developing in MVC framework there are three separate concerns; view, controller and the model. Each of them is independent of the other one.
Avoid Premature Optimization
This principle is the same as YAGNI, the difference is that it forbids the programmers to implement speed up algorithms before it is necessary. You never really know where the bottlenecks of the program would reside. You can only guess and the possibility of being always correct is quite minimal. So, it is better to achieve your milestones first and then to watch your program’s profile to find bottlenecks and implement speed algos.
Clean Code > Clever Code
Get over the obsession of writing clever codes. There are many programmers who want to show off their intelligence in the chunk of code by packing as much information as they can in a single line or by creating a weird function by playing with the intricacies of language.
Try to add up comments with the code section by following the style guides.
So, do follow the programming principles and make your life easy. And also create easiness for others. This is a rule of professionalism. And if you are ever terrified of coding, you can always read my blog to blow off this fear.