Dennis Calazans | Leonardo Paiva | Rodolfo Dias | Thulio Philipe |
---|---|---|---|
@denniscalazans | @leonardopaiva | @rmdias | @thulioph |
Development > Organization > Good practices > Standards...
SSP is a easy way to modularize and organize your project. Bringing the idea of OOP to JS, but in a simple way.
Using it you gain:
- readability
- Understanding of the parties
- modularization
- reuse
- adaptability
<script src="js/SSP.js"></script>
// SSP.MyModule.js
SSP.MyModule = {
setUp: function() {
console.debug('My SSP module is runing!');
}
}
// SSP.MyModule.Child.js
SSP.MyModule.Child = {
setUp: function() {
console.debug('My SSP module is runing!');
}
}
<script src="js/SSP.js"></script>
<script src="js/SSP.MyModule.js"></script>
<script src="js/SSP.MyModule.Child.js"></script>
<script>SSP.init();</script>
All modules have a property called namespace that returns string
the name of the module.
SSP.MyModule = {
setUp: function() {
var self = this;
console.debug(self._nameSpace);
// return -> 'SSP.MyModule'
}
}
This method initializes all modules from your application.
SSP.init();
It is also possible to initialize a module each time calling the module by name, and multiple modules using commas. ```javascript
SSP.init(SSP.MyModule);
SSP.init(SSP.MyModule, SSP.MyOtherModule);
### > .setUp( )
----
SetUp is a Main method. It always runs when the father's module is called.
```javascript
SSP.MyModule.setUp();
Using this method, you can create an anonymous function able to invoke a method inside a determined scope.
SSP.delegate(scope, method);
Using SSP.readModule(Module);
you can run a module that's located in other module/part from your application. For example:
SSP.readModule(SSP.MyModule);
SSP.getByNamespace('namespace')
is used to return a object module using your namespace in string
.
Using this method you don't run the module called, this module only returns the object module and the features.
SSP.getByNamespace('SSP.MyModule');
return - > Object {setUp: function, Child: Object}
Using SSP.applyByNamespace('namespace');
you can run a module that's located in other module/part from your application, but using _namespace
. For example:
SSP.applyByNamespace('SSP.MyModule');
Using that method you will run the called module using _namespace
.
SSP.initModuleByNamespace('SSP.MyModule');
- Fork it!
- Create your feature branch:
git checkout -b my-new-feature
- Commit your changes:
git commit -m 'Add some feature'
- Push to the branch:
git push origin my-new-feature
- Submit a pull request :D