1. Write Clean Code (Obviously!)
Bear with me here.
So I haven’t always been the cleanest coder in the team. Through my struggles, I always find it annoying that people don’t understand what I wrote. Heck, I am annoyed that I can’t understand what I wrote a month ago.
I thought, “Hey, why don’t I try to write cleaner?”. Well, sometimes cleaner code doesn’t always mean someone else will understand what the code means at first glance. Because there are other factors at play like the business process, etc. But it helps — I guess.
Don’t Repeat Yourself (DRY)
Let me tell you, no one annoys me more than myself. I honestly can’t explain how frustrated I am when I read old code that has multiple copies.
Trying to understand multiple copies of the same lines of code at different points in the documentation is really confusing.
So ever since I realized that I tried to write functions for code that I would be reusing often. Boy did that save a lot of headaches.
If you don’t do that you might have to change multiple documents that literally have the same line of code just to let’s say — add a new condition to an if-else statement. Take it from me, sometimes you can forget and bugs will happen. So please, write code you going to reuse in a function.
Speaking of functions…
Code Purposeful Functions
What I meant by purposeful is that you have to write functions that have one exact purpose. For example, I want to hash passwords so I would obviously write a function specifically to hash passwords.
This will add even more readability to your code and it will save you a lot of headaches when you need to say — change the hashing algorithms or whatever.
But don’t go too overboard, if you feel that you don’t need to write a function for that .ToString() method in C# than don’t. It’s already readable. Don’t overdo it.