3 ms·
- Use a proper IDE, and note a text editor with 45 plugins. - Use strict typing whenever possible. PHP has scalar typing now, and TS for JS. - Use static anal
by Ayesh 6y ago
- Use a proper IDE, and note a text editor with 45 plugins.
- Use strict typing whenever possible. PHP has scalar typing now, and TS for JS.
- Use static analyzers and bake them to your CI workflow.
- Unit tests.
- Test your unit tests with mutation tests.
Overall, non-sloppy code takes more time, and you'll often find yourself spending more time in tests and code architecture than writing the core code. But in the long term, it will save time. I'm refactoring a project I worked 6 years back, and the test suite brings tears to my eyes, looking how thorough it was, which made the code decoupled, ending up me spending just a few days to refactor it all!