What we are preaching is nothing new. I suggest that you go check out Clean Coders by Uncle Bob.
If you are creating a new client side payroll system. You will have simple use cases like 'Pay hourly employee'. At this point how do you know which framework will best suite you?
DON'T make the decision now! Use this to create classes and core code bases and 'plugin' to the rest of the application architecture. Your application is the use cases, not the view.
There are many ways to install this.
npm install this
Will download the this library to your project.
You can also get the code from GitHub.
Once you have got the this_0.1.3.js
As soon as the script has loaded you are ready.
This is a tiny library. But you can find out more about it here.
Now you have this installed you can start writing classes.
With this, you can write your classes however you want. We prefer writing them in a closure like TypeScript.
var Greeter =thisgreeting = message;return "Hello, " + thisgreeting;;return Greeter;;
This creates you a basic class. This is doing nothing here.
The main ability of this is inheritance.
Every Function Object can be extended with this.
Simply use the Extend function after you have created the constructor to extend the 'Super' class and all the classes it also inherits.
var Person =thisname = name;thisage = age;console.logwords;;return Person;;var SuperHero =thispower = power;// Calls the Person constructor to pass the mandatory arguments.Personcallthis name age;// Extends the Person.SuperHeroextendPerson;console.log"Using " + thispower;;return SuperHero;;
You must extend after you have defined the constructor. Here we add the Person or super class to the Prototype Object, which means you have to add all your public methods after extending.
Let me know if you have any new features that you think would be good. Or any improvements that can be made. Post on the issues page GitHub Issues.
Copyright (c) 2013 Ricky Clegg
Licensed under the MIT license.