There is a strategic PHP operator that you should always use in all your apps. It's this one:
/* */
Yes, the
comment operator.
Comments are like data backups. We know they are important. But for some reason, we always want to think about them... later. Only when it's too late, we realize how important they are.
This is what usually happens:
You write a nice piece of code.
You think that you will remember what that code does forever.
... time passes...
... and a few months later, when you need to reuse your code, you don't remember anything
about it anymore.
Yes, writing comments takes time. But trying to reuse your old, uncommented code? That takes much more time, for sure.
It's important to understand that comments are not just about good coding practices.
Above all, they are about productivity.
And for a web developer, productivity is really important (to say the least). You see, during my years as a web developer I have learned this fact: you will reuse your own code a lot. For example, very soon after my employment, I wrote a user management class. Year after year, I have improved it many times and now I use it in most of my projects. Thanks to that, I do not need to write a new authentication class every time, wasting many hours in the process.
Without comments, I could never have been able to keep working on the same code and save so much time.
Writing new code is one of the most time consuming
activities. New code has to be implemented, tested, fixed and optimized.
If you want to stay competitive, you cannot waste your time writing the same code over and over again. Or worse, trying to understand how your own code works because you can't remember it.
This is what comments are really about: they let you grow your own code library and make it better and better with time.
That's all for today. I hope I made you at least a bit interested in using comments :)
Now it's your turn: send me a reply with your questions and thoughts. What do you think about comments?
Until next time, Alex
Share the knowledge
Did you like this email? Share it with your friends and colleagues. Click here to share it
Why do some PHP apps get hacked and others don’t?
Are your apps safe from web attacks? You are not so sure, are you? You only hope that your code is secure. And that keeps you constantly worried. But with the right defense techniques, you can protect your apps from all kinds of attacks. So you can finally feel safe and stop worrying.
PHP Security Mastery is my personal course that will teach you exactly how to make your code secure. Click here for the details.
Need help with your PHP code?
If you can't make your PHP code work, you can ask me for a Code Review. I will verify your code, fix it and make sure it works the way you want. Click here for the details.
Resources
Alex Web Develop- My blog where you can find my tutorials. Alex PHP café- My Facebook group where you can talk with me and other developers.