Angular or React?
Before I write about a topic which has been widely discussed and debated, I'm obligated to explain why I chose to spend time to write this. The answer is more of ideological than practical. I do not believe in comparing Angular with React or any other from myriad of front-end frameworks. Contrary to popular belief, I choose to believe that both React and Angular can co-exist and can be utilized to solve a totally different and unique set of problems. With this article, I'm trying to prove this exact point. Which, surprisingly, most of the articles have missed to mention.
Unlike other articles which compared these with Packaging, abstraction, learning curve, etc. I'll be explaining a case where Angular would be more suited and easily employed, and another where React wins without a contest.
The curious case of Angular
As we all know, Angular is not AngularJS. Even though both share name and some patterns, the purpose of both are clearly different. Just to be clear, all the point I consider here in this case, will be applicable only to Angular.
Case : I Own a Health band company
And my customers should be able to do,
- Provide details about themselves, such as Address, name, email, and phone number.
- Search my catalog and add new product to cart & checkout.
- Check their health status and book doctor appointment if necessary.
All these actions are independent and usually done only one at a time. Here, most of the actions are driven from users themselves, and usually there is more or less no data sharing between these actions. In this case, I would choose Angular for my front-end application, because,
- I can segregate the entire application to many parts, and the each module can be separated without worrying about other modules. ( Can be debated)
- All my forms need validation, and Angular has best-in-class form validation framework.
- The application behavior is different. From module to module, screen to screen. I do not have to worry about million other packages and which one suites my needs. Angular got me covered.
A web app which is not much data-centric and does not need a tight connections between actions, but has a huge requirement with very little time, would be easier to develop with Angular.
State of React
I like the way React tries to solve one problem efficiently, UI performance. But to maintain state properly, I need to go with Flux or Redux. Which is absolutely fine, because I might not need it always.
Case : I'm building a budgeting app
And the app should be able to,
- Get the money spent from user input / other service
- Provide account / bank based status.
- List monthly expenditure and display on what most of the money is spent.
- Provide an option to search transactions done. Probably across accounts. And modify / delete individual transaction.
All these actions are clearly interlinked and should be from the same database. The actions are tightly woven to each other and any changes done in page A, will affect the graph / list displayed in Page B. In this case, I would choose React. Because,
- The source of data "store" can be easily trusted as all the changes should go through only one dispatcher. And changes will never go non-notified.
- React provides a very clean linkage between the store management systems and components, ensuring that the page is accurate.
- The application behavior revolves around the same set of data, and each action is highly dependent on another action performed.
A web App which is clearly data-centric should go with React. This approach effectively removes the data change head-ache, and in-turn reduces the development time drastically.
And hence, I would re-iterate my dialog that both can co-exist and create an application which would have been hard to conceive with other framework. Also, I would appreciate any comment or suggestions.