Sometimes it can be convenient to stop and think about how to improve the existing one and write Angular good code, rather than go ahead without thinking.
Below I have collected some small rules that I try to constantly follow and which I hope will be useful to you too.
1) Always “type” everything where possible.
One of the features introduced by Typescript (on which Angular is based) is the possibility of making explicit the types of data (in variables and signature of the methods). This allows you to know what is going in/out of the flow of information and helps to keep the situation under control.
2) “Stay tuned” but with caution.
Keeping up to date for a developer is the foundation. This is particularly true for Angular, which is updated frequently, advancing version practically once a year. A feature, which is new the previous year, the following year may already be deprecated. However, you must be careful not to use regardless of the latest version because some third-party libraries may not support the innovations introduced.
3) Scaffolding is the way.
Get in the habit of using scaffolding commands to create components/services/etc. to be sure you don’t make stupid mistakes or a typo and you are in a ready-made frame of what you need.
4) Pay attention to order and file structure.
Always keep your file structure as close as possible to what is the standard. This allows you to get used for when you go to see other people’s code that will follow this rule. When you need to look for something, you will already know where to go to look because it has been clearly categorized.
5) Less is better for Angular good code.
This rule can also be used for any programming language but is applied particularly well in a JS sauce framework like Angular (since it is code that runs on the machine of an unfortunate user).
Having less code to manage in the long run is good for have clear mind when checking or pointing to the “new”.
That’s all for Angular good code.
Try these advices at home!