📜 ⬆️ ⬇️

5 reasons to use AngularJS in your corporate application

5 reasons to use AngularJS in your corporate application


image

The current situation in the world of enterprise applications can be described in one word: chaos.

Starting with the obsolete code, which for N years passed from the developer to the developer without any documentation. Too complex interfaces that make code too complicated. Before mixing together N technologies in one single application. Let's face the facts: when these things were created, no one thought about their support. Today we have a problem - how to fix all these applications? Where to begin? How to bring common sense into them? How to bring them to the modern technological stack?

This post presents my opinion on why using AngularJS in corporate environments will not only bring common sense into your applications, but also allow them to evolve.
')
1) Start gradually

In a corporate environment, you are more likely to come across an ugly abandoned project than a new and fresh one. With a project that has been redrawn many times. Understanding it is so difficult that developers often throw out the code and rewrite it. This, of course, affects both cost and time.

With the AngularJS framework, this does not happen. You can start by including it in some places of your application that you can slowly start rewriting. Believe me, I did it before, and it really WORKS. And it not only works, but also allows you to lay the beginning for a wonderful application. Given the fact that you can put the ng-app anywhere, you can say, for example: "Hey, why don't we start updating this application from the home page." Then your back end developer writes web services (yes, I’m a front end developer), you start writing your tests with Karma Test Runner and very soon you suddenly have Controller, View and Model for the application home page. All this is controlled by AngularJS and beautifully encapsulated in its own little world. My friend, you just did a very very good deal.

2) Fast adaptation by developers

Technology is changing so quickly that keeping up with the times has become quite a challenge. Either you have the right ways of learning, or you are tormented by reading various O'Reilly books, and trying to figure out how all these things work.

One of the great things that has recently become widely known is the Javascript MVC framework. They owe their appearance to the fact that the community understood how difficult it became to support and understand Javascript. Javascript MVC frameworks are a good tool that you need to learn and use if necessary. For example, in our case, in web applications.

In the case of AngularJS , even if you know absolutely nothing about JavaScript MVC frameworks, you can safely open the official website of AngularJS , watch the training video (by the way, pretty cool) and after about 10 lessons (15-30 minutes) you will know exactly where to start and how to create an application using Model, View and Controller (MVC), and, importantly, be able to test it all.

This allows large teams to simply access the Internet at any time, get training on the site, and since they learn from one source, team members can ask each other questions and learn the framework at their own pace. This is especially important if you have a team whose members work remotely from each other.

3) Performance and Scalability

The ability to quickly build a project with all the necessary details is the key to quick start up and efficiency. In my memory there were projects when it took about a week only for everyone to install and familiarize themselves with everything that is necessary for the project. This slows down performance and is a clear sign that something is missing.

To fix this, we can use Yeoman . Yeoman is a workflow consisting of a collection of tools that allow you to quickly start, run, and assemble projects.

Yeoman works pretty well with AngularJS (which makes sense, since they are part of the same family). Yeoman will allow you (using generators) to create the AngularJS repository, which will include the latest version of Twitter Bootstrap , various angular pieces, Karma Test Runner , etc. And also glue it all together by simply initializing the repository in a folder with any name (preferably associated with your application). Yeoman will use this name to create the application namespace and at the same time will create a sample of the type associated with the controller sample associated with the test sample.

This structure not only allows you to quickly collect something, but also creates the basis for building something much larger. In addition, once you are ready to release, just run the grunt command and your files will be compressed and combined (use ngmin ) and placed in a separate folder. Isn't that great!

Among other things, since you are creating a single page application, everything must be RESTFUL , that is, this application can and will interact with ANY backend if it issues a suitable JSON. Since we share code and logic, the application will be easier to scale and develop.

4) Tests Tests Tests

Situation: there are thousands in the project, maybe hundreds of thousands of lines of code. You were thrown right in the middle. There is no documentation and urgently need to implement a new function. You start messing around with the code and you soon realize that something else has broken down, and you have no idea why ... now you have to spend hours, maybe days of wandering around confusing code, to understand how your changes broke something else ... bad , very very bad.

One of the most important things to maintain a large amount of code for a long time is the use of tests. With the help of the Karma Test Runner , which AngularJS generators in Yeoman will give you, you can constantly perform unit tests in the background. Thus, if you change something and click “save”, your tests will be automatically executed and you will immediately find out if you broke something where you broke it, and if the tests are built correctly, then maybe even why it broke.

This is very useful because usually developers insert a new piece of code as follows. They add 10-15 lines, save, and bang, something breaks. Then they comment on 8 lines of code or something. Save, restart, still not working? Not? Clearly, the error must be in these 2-5 lines.

It is much easier to do this than to navigate through N files and hidden dependencies and try to understand what the previous developer was thinking about when writing this.

5) Good community support

Often you are stuck in one piece of code and you have no idea why it is not working. Until now, the community has never let me down when it came to help with solving the problem. I ask a question on Stackoverflow or in the Google group and after a few hours or even minutes I get the answer I needed, sometimes even from the AngularJS development team itself! And it helps not only you, because when your problem is solved, other developers can use this solution for themselves. This speeds up the learning process and the detection of any potential failures. It is, in essence, a process concluded in itself that continues to evolve and grow.

Conclusion: Using the very self-confident JavaScript MVC framework like AngularJS is a great way to start cleaning up old code, starting small and bringing sanity to your project step by step. If your development team is not at the forefront, they can get AngularJS online training at their own pace and learn how to use it. When they are ready to develop, they can turn on Yeoman and start using such an “upgrade” within a few minutes using AngularJS , Twitter Bootstrap , Karma Test Runner and many other buns provided by Yeoman . When a developer starts a build, he can use the design through test method to create unit tests and test scripts for everything he builds in AngularJS . This will guarantee that if in the future someone new joins the project and wants to make changes, it will be much easier for him to do it. And with a great understanding of what its code will affect.

AngularJS is not the ultimate bulletproof solution, but it helps pave the way for cool things that will be presented in newer versions of JavaScript, such as Object.observe, a better controlled scope, etc. In theory, these innovations (and I myself believe in this) will bring order and more natural development methods into all applications that use JavaScript.

Source: https://habr.com/ru/post/223425/


All Articles