We have been investing plenty of personal time and energy for many years to share our knowledge with you all. However, we now need your help to keep this blog running. All you have to do is just click one of the adverts on the site, otherwise it will sadly be taken down due to hosting etc. costs. Thank you.
Everyone have their own opinion when it comes to coding practises but at least we all should do our best to follow official standards and best practises to make our code easy to understand, easy to follow, easy to refactor, easy to work with so on. The list below consists of some, not all, standards and practises that I tend to follow. Note: The most of these apply to PHP.
- I follow PSR-2 Coding Style Guide.
- I use TDD (Test Driven Development) framework PHPUnit and PHPspec.
- I use BDD (Behavior Driven Development) frameworks like Behat.
- I version my code with Semantic Versioning.
- I try not to define more than 5 method parameters.
- I try not to have more than 15 methods in a class.
- I try not to have more than 25 lines of code in a method.
- I try to keep "public" methods as thin as possible and do most of the work in "private" methods.
- I avoid having God objects in my applications.
- I follow DRY, SOLID, The twelve-factor and Law of Demeter principles.
- I analyse source code and fix PSR coding standards issues with PHP-CS-Fixer or PHP_CodeSniffer.
- I use PHPStan and PHP Mess Detector to look for potential problems or bad smell within the source code.
- I use PHP Copy/Paste Detector.
- I use phploc to measure the size of my projects.
- I use Roave Security Advisories to ensure that my applications don't install composer packages with known security vulnerabilities.
- I try not to introduce unnecessary functionality because You aren't gonna need it.
- I'm aware that Worse is better.
- I follow Agile software development methods.
- I always use GIT, apply git-flow and branching model techniques.
- I always consider refactoring my code.
- Before and while coding I tend to use ERD and UML modelling techniques.
- I don't like Cargo cult programming.
- I believe that all UI and UX people should understand Principle of Least Astonishment.