What we are preaching is nothing new. I suggest that you go check out Clean Coders by Uncle Bob.
###Quick Explanation 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.
###Method Behind The Madness
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.
- 2012/25/2 - v0.1.7 - Added Bower ignore list.
- 2012/25/2 - v0.1.6 - Added component.json to publish to Bower.
- 2012/25/2 - v0.1.5 - Added tests for EventDispatcher. Added Array.indexOf.
- 2012/17/2 - v0.1.4 - Updated API, added EventDispatcher but not yet tested.
- 2012/14/2 - v0.1.3 - API update.
- 2012/13/2 - v0.1.2 - API update.
- 2012/12/2 - v0.1.1 - Documentation update.
- 2012/10/2 - v0.1.0 - First release on includes extending.
- Simple Event dispatching.
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.