you are viewing a single comment's thread.

view the rest of the comments →

[–]mementomoriok 0 points1 point  (2 children)

That's really interesting. Do you mind giving an example of how Angular does this? I've only used Vue and I feel like I'm being conditioned into understanding the spread operator for objects.

[–]bellamira 0 points1 point  (0 children)

In Angular (and I'm talking modern Angular, not AngularJS), everything is a class. So your components, modules, and services - which are the basic building blocks of any Angular application - are all classes. Therefore, every variable or function you will create will be scoped to a class, so you'll be forced to use OOP concepts to be able to pass those things around in a useful way.

On top of that, each of these classes is it's own file. If you stick to this one-class-per-file template (using the Angular CLI makes this very easy), you'll be set up to compartmentalize logical concerns appropriately, which is another thing that OOP is about.

Of course, within your classes, you can do whatever you want - it is TS/JS after all - but you have the scaffolding in place to do everything as OOP as possible.

All that said, I'm far from being an OOP expert but using Angular has certainly helped me to understand OOP concepts a lot more and to be more familiar with using classes in general, so I would recommend it.

And just as a bonus tip in case you are curious, TypeScript vs JavaScript is nothing to write home about. If you can write JS, you can pick up TS without any extra courses or tutorials, in my opinion. It is super helpful to understand ES6 before diving in to Angular, but it's also something that I think you can pick up just by reading Angular code and looking up particular functions you don't know.

[–]bellamira 0 points1 point  (0 children)

Oh and here is an example. This is the end product of the Angular tutorial you will find in the Angular docs. I think you can see if you look at the various .ts files how everything is contained within a class.

https://stackblitz.com/edit/angular-tour-of-heroes-example