![]() |
Best practices for all programming languages. |
Introduction
Do you want to sound like the real senior developer? Here's where you can get started. You may be a senior developer, a tech lead, or a junior developer. Your programming style can determine the quality of your work. You may have 10 years of programming experience. But your real quality worth can be determined in seconds by looking into your code. Here are some best practices you should follow, in order to sound like a pro.
Contents
- Using appropriate names while declaring variables, functions, or creating a file.
- Using camel and pascal case convention for variable, functions, and class name declarations.
- Formatting/Prettifying your code.
- Avoiding unwanted whitespaces.
- Adding comments wherever required.
- Avoiding Hardcodes.
- Shortening your code as much as possible.
- Do not Repeat Yourself aka DRY principle.
- Refactoring and optimization of your code.
- Measuring the performance of your code.
Explanations
1. Using appropriate names while declaring variables, functions, or creating a file.
When you declare the new variables or when you add/alter column names in the database, or when you creating a file please use appropriate names, etc. It will help you and your colleagues in the future to understand what's going on.
2. Using camel and pascal case convention for variable, functions, and class name declarations.
While declaring variables or adding/altering any table columns in the database, use the camel case. For class names, use the Pascal case.
🚀 Example:
3. Formatting or Prettifying your code.
😎 More prettier is clean ✨.
4. Avoiding unwanted whitespaces.
🤑 Quick tip: Format your code while saving or enable auto-formatting while saving will help you to reduce unwanted whitespaces on the go.
5. Adding comments wherever required.
6. Avoiding Hardcodes.
🤑 Quick tip: Create a new file in a separate folder like statics or environment to keep all of your hardcoded values such as response codes, response messages, color codes, some standard values etc.,
7. Do not Repeat Yourself aka DRY principle.
8. Shortening your code as much as possible.
🤑 Quick tip for Javascript developers: Try to use ES6 features and Array methods to shorten your code as much as possible rather than using traditional javascript features.
9. Refactoring and Optimization of your code.
🤠 Quick fact from google analytics: Bounce rate will be higher for websites/applications whose response time is slower.
10. Measuring the performance of your code.
- Constant O(1) - 😍
- Logerthemic O(log n) - 😀
- Linear O(n) - 😒
- Quadradic O(n²) - 😨
- Exponential O(2ⁿ) - 🤯
🎉 Thanks for reading this article. Hope I have given you pro tips to make your code clean. Practice these steps to sound like a real pro senior developer. I am very happy that you spent your time on something good. Please comment and share this article with someone who really needs this. Thanks again and stay connected for more interesting posts.
And special thanks to my seniors for encouraging me to write this article.
This helps
ReplyDeleteI am so glad that I helped you 😊. 🎉 Congratulations for spending your time more valuable.
Deletewhat a brilliant idea .
ReplyDeleteThanks for the comment 😎. Keep away from 💩.
DeleteThanks for your support 🙏. This kind of support really motivates me for posting further articles. Stay connected for more posts !!!.
ReplyDeleteVery informative, keep posting
ReplyDelete