Why I Chose Angular Going Into 2020
Three good reasons
Angular is Opinionated
I got into web development through learning Ruby on Rails back in 2015. I loved it. I enjoyed many different things in Ruby on Rails — one being how it’s an opinionated framework. For those who don’t know, an opinionated framework is one that has a certain way of doing things, which developers are pushed to follow, at least to an extent.
Some of you may not like the restrictions and would prefer the flexibility and freedom of setting up your project in your own way. If that’s you then you’d have more control over that building your web app in React.
I enjoy this because as soon as you set up your project using the Angular CLI, you get a template engine, a router, form validation, reactive programming RXJS, a guide on how to structure your code and how the data should flow in an application. It also makes it a lot easier for other developers to pick up someone else’s code.
For example, by using types you can tell what type of arguments a function takes in and what value it returns directly from the IDE. This saves you the hassle of doing a
console.log() to figure out what goes where.
What’s also a huge plus is that TypeScript offers dependency injection and it’s heavily used in Angular as it lets you inject services and other classes into a component giving that component access to those classes.
This is not just an Angular thing, you can add it to any project and use it in more or less the same way. But it comes shipped with Angular and it’s used in their built-in services like the HTTPClient which is the defacto way to make HTTP requests from an Angular app. RXJS gives you a lot of power with minimal code.
Let’s say you make a get request and find out that the format of the response is not what you wanted. Adding an operator like
switchMap will let you alter the data and return it the way you want. If you then decide to let the returned value have some other modifications you can add another operator easily. And for the times when you can’t find an operator that does what you want it to do you could build your own custom one.
So refactoring or adding extra functionalities to existing code can be made relatively easily. RxJS is also great for state management as you can create an observable and subscribe to it from multiple places — when a change happens to the main observable, it is emitted to all the subscribers.
Angular might be harder to learn than Vue and React, but once you get familiar with it, you have an all in-one-framework that can be used for hybrid mobile/PWA development (with Ionic 4), is supported by Google, has very good documentation, and comes packed with features to tackle your next project.