BriaBytes

View Original

Why I Write My Comments Before My Code

Yes, I know it’s been months, but life be life-ing, you know?

Let’s just jump right in:

When I’m about to dive into a new coding project, the first thing I do is write my comments before writing any actual code. It might seem a bit backward at first, and I’m sure someone would say it’s a waste of time, but trust me, it makes a world of difference for me. After finding this post I decided to adopt this practice, because I was just starting to learn how to code. Here’s how it helps me.

Getting My Thoughts Straight

Starting with comments helps me get my thoughts in order. Before I start coding, I need to know exactly what I’m trying to achieve. Writing down what each part of the code should do helps me clarify my intentions. It’s like sketching a rough outline before writing an essay – it gives me a clear path to follow.

Planning Like a Pro

Comments act as my roadmap. They break down the problem into smaller, manageable steps. By planning out the logic in plain language first, I can spot potential issues early on. This way, I can tackle each part of the project systematically without feeling overwhelmed by the bigger picture.

Upping the Quality Game

Having a clear plan laid out in comments ensures that I don’t miss any important steps. It’s like a checklist that keeps me on track. This not only leads to more thorough and complete code but also helps me write cleaner and more efficient solutions since I know exactly what needs to be done.

Teamwork Made Easy

If(when) working with a team, my pre-written comments would give everyone a peek into my thought process, making it easier for others to understand, review, and contribute to the code. It’s a great way to keep everyone on the same page and make collaboration smoother.

Future-Proofing My Code

Months down the line, when I revisit my code, those comments are like breadcrumbs leading me back to my original train of thought. They make it so much easier to debug, refactor, or add new features without spending ages figuring out what I was thinking when I first wrote the code.

Wrapping Up

Writing comments before coding might seem like an extra step, but it’s totally worth it. It helps me stay organized, plan better, write higher-quality code, collaborate more effectively, and maintain my codebase more easily. So next time you’re about to start coding, try writing your comments first – you might find it as helpful as I do!