DEV Community

Cover image for Simple Hacks to Level Up Your Coding Skills
MD Mohsanul Hoda
MD Mohsanul Hoda

Posted on

Simple Hacks to Level Up Your Coding Skills

During my early years as a front-end developer, I was part of a team where the Tech Leads emphasized the importance of 'clean' code.

Looking back, I understood what they were asking: my code needed to be clear and descriptive so anyone could easily understand it. If someone reviewed my code, they should quickly grasp how we addressed the client's user stories. The goal was to produce code that was both readable and maintainable.

Think of your code as a conversation with future developers, including your future self.

This post highlights key points to remember when writing clean code.

1. Use Descriptive Names:

Variable and function names should be as descriptive as possible.
I always advise programmers to name their variables with things that actually make sense to the reader. Write code as if someone else was supposed to read it afterwards.

Descriptive Names

2. Minimize the use of comments

Maintaining code can be challenging, and maintaining comments can make it even harder. How can we avoid relying on comments? By using descriptive names. If our code is self-explanatory, comments become unnecessary. 

The problem with comments is that when someone changes the code, there's no guarantee that the person updating it will also update the comments, leading to inconsistencies. Remember, if you feel the need to write a comment, it may indicate that the code isn't as clear as it could be. However, if you need to add comments, do so only in exceptional cases where they are essential.

Minimize the use of comments

3. Reading documentation

Learning a concept directly from the official documentation is often the most reliable and effective approach. Official documentation is created by the developers or maintainers of the technology, ensuring that the information is accurate, up-to-date, and comprehensive. It covers all essential details, best practices, and edge cases, providing a solid foundation for understanding the concept. 

Unlike third-party resources, which might contain outdated or incorrect information, official docs are continuously updated and serve as the most authoritative source for learning.

4. Develop strong debugging skills

Learning to debug correctly is an essential skill for any developer.

Use debugging tools, console logs, and breakpoints strategically to trace and inspect your code's behavior. Remember, good debugging is not just about fixing errors but also about learning why they happened, so you can prevent similar issues in the future.

5. Implement a version control system. (eg: GitHub, Bitbucket etc.)

Always make a habit of pushing your code to the repository, not just when you are working in a team but also when you are developing a project alone. This practice protects your code from loss and helps maintain proper version control.
Some tips for maintaining a Repository.

  • Use descriptive names in your commits, do not use names like "Fixes", "Refactor," or "Minor changes."
  • Review all your changes before making any commits.
  • While adding any new functionality, create a branch, and if it works fine, merge it only into the main branch.

6. Learn the art of using Google, AI, or any other platform

"Think of AI not as a competitor, but as a supportive partner". 
 Always try to search for any error with proper keywords and don't just copy-paste the code from Stack Overflow or ChatGPT, first understand it and write it in your own words with proper descriptive names.

7. Code Review and Collaboration

Reviewing your code by peers can reveal optimization opportunities you might have overlooked. Code reviews are a valuable part of the development process, leading to better and more efficient code.

8. Update Yourself

Staying updated with current technology is essential in today's fast-paced world. It enables professionals to adapt to new tools, frameworks, and trends, enhancing their skills and productivity. By continuously learning and embracing the latest advancements, one can remain competitive, innovate, and tackle challenges more effectively. Keeping up with technological changes also opens up new opportunities, driving personal and professional growth.

Adopt the practice of expanding your knowledge daily.

9. Develop the confidence to ask for guidance

It's crucial to develop the ability to ask for assistance in both personal and professional contexts. It demonstrates humility, a readiness to learn, and an awareness of the fact that teamwork frequently produces superior outcomes. Seeking assistance can open your eyes, speed up problem-solving, and create a welcoming environment where people can grow from one another. Recall that asking for help is a sign of strength rather than weakness since it shows that you value cooperation and group expertise.

10. Utilize unit testing and follow the principles of Test-Driven Development

I understand that unit tests may sometimes seem like a waste of time, but that's far from the truth. In fact, unit tests are highly effective. Consider this scenario: months after you've written your code, a new developer joins the project and adds new functionality. However, their changes inadvertently break existing features. How can you or the new developer quickly identify these issues? If the project has unit tests in place, detecting such problems becomes much easier. I realize that deadlines can be tight, but the time you spend writing unit tests can save significant time and effort in the future.

As a best practice, start by writing your unit test first. It will likely fail at first, but that's okay. Proceed to develop or update the code, and then run the unit test again. This time, it should pass. This approach not only ensures your code is working correctly but also allows you to approach problem-solving more effectively.

Design your logic before you develop.

Thank you so much for taking the time to read my work. I hope you found it helpful.
If you enjoyed this article, please consider subscribing to Medium through my profile. Thank you!

Top comments (2)

Collapse
 
oculus42 profile image
Samuel Rouse

Thanks for sharing this! A lot of these are built up with experience and time, and sharing them for newer developers can help a lot.

Point 1 is just a single sentence, and uses the same image as Point 2. I think this might be inadvertent, as it doesn't appear as relevant to the topic.

Along with using version control like git, the meaningful commit messages are really important. The commit messages are also part of the conversation with future developers! We've started using Conventional Commits to help guide developers to create those meaningful commit messages. This also helps our CI/CD tools identify version increments automatically.

Collapse
 
mdmohsanul profile image
MD Mohsanul Hoda • Edited

Thank you, Samuel, for bringing the issue with the same image. I’ve fixed it.