Give the code statics

Yes, I know, statics and static code analyzer has nothing common in the first place, but at last will code be better by using them. Harder. And so they contribute to a solid code structure that makes our applications more stable and better.

Roland Golla writes in the edition 5.2021 of the Entwickler Magazin: "Legacy code makes sick." His article is about PHPStan. How you integrate this static code analyzer in your development environment (and that doesn't mean your IDE only), not only to identify undiscovered sources of error but to improve your skills and your knowledge as developer.

You just can't know everything, development in PHP takes place in ever shorter release cycles. On the other hand, the customer's aging application is maintained. Every developer has to cover an enormous range of features that are made available by the PHP version used in the respective project.

In my opinion, the unbelievably beautiful and always fascinating thing about being a software developer is that you learn something every day. Really every day. And tools like static code analyzer can help. I think everyone knows the feeling when you look at code from three, maybe four years ago, shake your head and then after a courageous "git blame" would like to sink into the ground when you realize that you have produced this legacy code yourself.

Static code analyzers start with the first development and help you to write a lot of clean code. They don't necessarily help you to write better program logics, so you can still nest the business logic so uselessly and implement it difficult to understand. But hey, there are other tools like Performance Profiler (Blackfire etc.) that you can throw at this problem.

I can only recommend tools such as PHPStan, rector, Psalm etc. to anyone, in addition to the tools such as PHP-CS-Fixer or PHPMD, which have hopefully been used for years. To analyze code, refactor it, and most importantly, learn. Quasi as pair programming with a tool and not with another developer. Or as a code review before the actual code review.

Disclaimer: Roland Golla made the above-mentioned edition available to me free of charge, for which I thank him very much. I've lost sight of print products for a long time when it comes to programming or topics on the web. But once again it was a wonderful experience to have paper in hand while reading. I will not make a subscription now, but if I should ever travel by train or something again, I will look for such magazines at the station kiosk. Otherwise, I can recommend his YouTube channel "Never Code Alone", which I follow regularly. His videos are mainly about testing, refactoring and general topics about being a developer.

Comments

No Comments

Write comment

* These fields are required