So once I finished creating BlocJams with jQuery, I started the next portion which was learning Angular - a Javascript framework. To do this, I pretty much recreated BlocJams.
First, I copied a cloned a basic template from Git that Bloc provided. Then I copied most of my CSS and HTML templates. I was very happy I didn’t have to recreate all of that code. Then we started setting up basic things like a module and controller and I learned a lot about dependancy injection and the preferred correct way to create services using function expressions. It was A LOT to take in at first and it took me quite awhile and a lot of extra research to try and figure out what was going on and how it was all working. Angular is a VERY different beast than anything I had learned before.
At first, it seemed like it was so much work to get even the most basic things set up. It seemed to require so much code to set up even the most basic things. When you have to first create a factory or something to control logic and you’re wondering why not just do it in a much more simple fashion. Then about mid-way through the project, it finally dawned on me. I guess I just had to see things in action to really realize what was so great about Angular.
First - organization. I can imagine that these huge sites like Amazon or Netflix have thousands upon thousands of lines of code. And if you they just crammed it all into a single file, it would be virtually impossible to work on. Trying to find the right section of code to change/test would be incredibly difficult and when you have hundreds (or thousands) of developers trying to work on this code, I’m sure it would be incredibly difficult to sort out, if not impossible. So having all of these logic divions split into different files and sections makes is so much more easily accessible and readable. You can go to a section of your website and know exactly what files are handling the logic for that portion so if you need to change something, it’s much easier to get to.
Second (and possibly even more important) - expandiblity. At first it can seem like this huge pain to create a new file and use all this boiler plate code just to create a new service or have to link a controller to this portion of your application and it can be tempting to want to just do it the “fast” way and write code that does what you want it to do. However, before long you end up having to copy and paste a lot of code because you want this other portion of your site to have similar functionality as another. Angular (and by extension I assume most frameworks) make this much easier. You may have to do a little more work setting up the code up front, but once you do, it’s extremely easy to “inject” it into another section of the site. You just literally link the service and voila, you have instant access to that code! So not only does that make it so much easier and faster to use the same code in various parts of your site, but it also makes it much cleaner and easier to read and work with!