Why I chose Angular π§
Juan Herrera
Posted on June 24, 2019
TL;DR
I chose Angular because together we make a great team. It provides a fully-fledged platform that takes care of non-functional requirements such as compatibility, maintainability and testability while I focus on the user.
What problem does Angular solve? π€
Frontend development has become increasingly complex.
Ever since we acknowledged the potential of the web, our interfaces got richer and our features got more sophisticated, but as our requirements grew bigger, so did our challenges.
To give you an idea, these are some of the aspects I have to take into account when building a large enterprise app today:
- A11Y βΏοΈ: Making websites accessible for everybody including but not limited to color-blinded, vision-impaired, motor-impaired, or hearing-impaired people. Cross-browser π»: Ensuring your website works seamlessly, or at least progressively, on almost every browser: Chrome, Safari, Edge, Internet Explorer, etc.
- Adaptive πΌ: Providing a UI and UX that can adapt to all kinds of screen sizes (TVβs or small devices), resolutions (retina, 2x images), and types (phones, tablets, desktops), etc.
- Multilingual π: Building websites that can adapt to different language structures such as RTL and LTF, plurals, currencies, etc.
- Performance πββοΈ: Creating websites that can be rendered under different network conditions such as 3G and on low-RAM devices in a timely fashion.
And this is just for the end-userβββthe developer has to deal with a lot of matters as well:
- Maintainability π©βπ»: Dealing with code bases that can easily reach millions of lines of code while ensuring proper developer ergonomics when it comes to modularity, scaffolding, and standards.
- Building π: Making sure your app bundles are lightweight so that you donβt surpass size budgets that would otherwise affect your performance and keeping an eye on any compilation errors and build times.
- Testability π§ͺ: Ensuring both unit tests and end-to-end tests run flawlessly, but also making sure creating new test cases remains straightforward despite the appβs complexity.
Note that for some applications, this is just an excerpt of the things you need, for some others, you can completely ignore these requirements.
For someone who is joining the software industry for the first time, this is just overwhelming.
As a professional, I'm responsible for understanding these challenges and knowing how to address them. Nevertheless, I don't want to spend hours figuring it out every time I create a new app. π€·ββοΈ
That's my problem, and that's what Angular does best.
What does Angular do? π€
Angular does a lot of things, but maybe this picture can give you a better idea:
All those nice icons up there represent a set of tools Angular provides. Let's go through some of them:
- π» CLI: According to large enterprises, the Angular CLI is one of the best features Angular is equipped with. It allows you to scaffold components, services and modules with just a simple command, but of course, that by itself isnβt very impressive. The real value of the CLI comes with heavier commands such as ng add @angular/pwa which automatically turn your app into a Progressive Web Application, or ng update @angular/core @angular/cli which automatically updates your app to the latest stable version of Angular. All of this is possible thanks to the power of Schematics.
- π Schematics: You can think of Schematics as the Yeoman of Angular, but with superpowers. Schematics is a code generator, it allows you to create and transform code. For example, instead of creating your TypeScript models over and over again, you can create a schematic that generates the whole class for you with accessors and all. However, this is just a simple exampleβββyou might as well use it for complex logic such as refactoring a large application to use external templates instead of inline templates in all their components! Doing it by hand took me 2 hours, doing it with Schematics just a few minutes π.
- πΌ Angular Material: It is a component library developed by Google that gives you access to a set of fully-tested components that work out of the box. It is initially themed with the Angular Material design system, but it also provides a CDK (Component Development Kit), giving you the opportunity to use whichever design system you need.
- π Http Module: The Angular team knows that HTTP calls are present in most web applications. That's why Angular comes with a module that makes it easier for you. It is based on Observables so you can compose your calls in any way you like. Besides, it has HTTP interceptors which allow you to transform your incoming/outgoing requests with ease.
- π i18n: Angular also provides built-in functionality through the Angular CLI to help you create multilingual websites. It reads your templates and generates the XLIFF (or XMB) files that can be used for translations of texts, numbers, dates, and currencies. Once you have set up your translations, the CLI will create the corresponding builds for you without any additional effort.
- π§ͺ Karma, Jasmine, and Protractor: Unit tests and end-to-end tests are a priority for the Angular team. That's why Karma is already configured in every Angular project, created with the CLI. You can use Jasmine if you wish or switch to any other framework of your preference. In the end, all you have to worry about is writing your tests.
- πΊ Router Module: Whether you are lazy-loading, pre-loading, or loading your routes on demand, the Angular CLI has a module ready to make it straightforward for you. It provides a maintainable structure that makes applications with heavy routing configuration easy to handle. You should only be concerned about the what while Angular cares about the how.
- π₯ Reactive Forms Module: Forms is one of the most common artifacts in web applications. Some are rather simple such as login forms, others are complex where some field values depend on other fields values and such values need to be validated on real-time in both the client and the serverβ¦ π². Well, the Reactive Forms Module helps you reduce the amount of boilerplate code you need to achieve this while allowing you to keep logic out of the template.
Of course, some of these features are far from perfect, but for now, they have saved me a lot of time.
Should I use Angular then? π€
Whether a tool is suitable or not depends on your current needs, circumstances, and challenges.
To me, Angular is very well suited for large challenges. Although, isn't the web a large challenge already? Ryan Grove provides an interesting point of view here:
If today we have better tools to help us do it well, then why not use them? A good reason would be the cost. For some people, mastering Angular can take significantly more time than learning other frameworks out there.
In the end, it's up to you to pay for it or not, but then, Henry Ford's quote comes in very handy:
If you need Angular but you don't learn it, you will realize you learned how to deal with every single problem Angular solves, but you still don't know Angular.
Thanks for reading! π
If you have questions about Angular or are not completely sure whether if Angular is a good fit for you, reach out to me! I'd be more than happy to help you figure it out! π
Posted on June 24, 2019
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.