4 ms·
Easy to change code is code you understand a year later. This includes: Easy to understand variable and function names. IDEs make autocompletion possible so d
by thdrdt 7y ago
Easy to change code is code you understand a year later.
This includes:
Easy to understand variable and function names. IDEs make autocompletion possible so don't fear long names. MyEasyToUnderstandFunction() is better than MyETUF().
Function names should describe what they do. CreateOrder() is better than NewOrder().
Make sure you don't use global/public state in any object or component. Public state is one of the biggest sources of failure and bugs. If you can, don't use it.
KISS: Keep It Simple Superstar!
But maybe the most important (for me): use separation of concern and context. This always helped me a lot. For example: if an email must be sent when a new order is created you can put the email code directly after the order creation code. This will ofcourse work and might even be valid code. But the component that creates the order should not be bothered with how emails must be sent. If you separate this, it will help you a lot to create maintainable code.