Angular has been around for some time now but a lot of us still struggle with scaling our applications to match the demands of the requirements. Drawing from the past several years of working with Angular apps for clients, I’ve made a list of nine major ideas that are often overlooked. These are patterns of implementation that can help accelerate the quality of your final product.
1. Figure Out Your Domains and Be Clear With Your Boundaries
One of the biggest mistakes new Angular developers make is that they jump right in, coding first and fixing later. We’ve all been guilty of this at some point in our careers — even if it’s not with Angular.
However, as we gain more experience, we quickly discover that good architecture and planning can cut down your development time by a good amount.
But how can we achieve this? Through the clarity of domains and boundaries.
There are different domains that you can structure your Angular app around, such as logical domains, theoretical domains, and functional domains.
But what’s a domain?
A domain is a collection of ideas that are similar in nature and fit into a particular category. The boundaries of these domains help us determine if a particular feature or functionality fits within a particular categorization.
Don’t just code your Angular app as-is. Put some structure on it by figuring out how things should be grouped and therefore determine how your components, flow of data and directives ultimately relate to one another.
2. Custom Directives Are Not Evil
Custom directives in Angular are not talked about enough.
The common perception is that components are modularized parts that come together to form the application. However, if we modify this thinking into directives as one of the major building blocks and components as the glue that stick them all together, the concept of true reusability increases two-fold.
This is because starting with custom directives is not the usual flow tutorials follow when it comes to creating a quick Angular application. However, for large scale applications where there needs to be a clear separation of functionality from custom features, custom directives are super handy.
The purpose of your component is to bring everything together anyway. Processing and manipulation of data are supposed to sit on the services layer (which isn’t just limited to http calls to your APIs).
The thing about custom directives is that they’re sharable across the codebase, they reduce duplicate code, and they can help you create a deconstructed app that is able to adapt to changes quickly. If you need to create a new view, all you need to do is to put the parts together rather than having to code everything all over again.
3. Centralized Data Storage Can Keep You Sane
RxJS is a big deal and for good reason. While it’s nice to have your state’s accessibility at your fingertips, when there are more than just your fingertips involved, things can get messy quickly.
This post is for paying subscribers only
Sign up now and upgrade your account to read the post and get access to the full library of posts for paying subscribers only.