Create a Model Base Class

InstructorBrett Cassette

Share this video with your friends

Send Tweet

You're going to test drive the creation of a robust model layer for an AngularJS application. To get started, we need a solid base class to encapsulate common functionality. In this lesson you'll use Javascript's prototypical inheritance to create the model base class.

Kevin
~ 10 years ago

Can Brett Shollenberger follow-up on how he would've done this using ES6's class syntax, particularly any steps he would've done drastically in a different way?

Shaun
~ 10 years ago

Extending native objects is generally a bad practice and I don't see a compelling reason to make an exception here.

Nolan
~ 9 years ago

Shaun, I'm interested to know why in JavaScript this is bad practice? I'm fairly new to JS, but in backend programming decorating native classes would be the right approach. Is there something in JS that causes this to be a bad practice?

Nolan
~ 9 years ago

Brett, first, humbled by your JS knowledge. A lot of this type of model functionality can be found in server MVC frameworks like RoR or Laravel Eloquent, etc. whereas this series and the ActiveSupport provides very similar syntax and functionality for Angular / JS. I'm assuming that if you already using a rich MVC backend model framework, that you would not find much value in implementing this model approach? Other than maybe the local features ActiveSupport. Is that a fair assessment or am I missing the point? Again, great content!

Francois
~ 9 years ago

Hi, I understand everything in this video except for the attributes parameter that is being passed to the base class and it's new function. It seems that it is never used and creates a lot of confusion for me. Why would they be there and if there is implementation missing for it where can I see the implementation?

Evan Gillogley
~ 9 years ago

Where do I get the code for this?