Skip to content

simplesingleton/SSP-simple-singleton-pattern

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

63 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

The Simple Singleton Pattern

The Simple Singleton Pattern - A solution to many problems

Team

Dennis Calazans Leonardo Paiva Rodolfo Dias Thulio Philipe
Dennis Calazans Leonardo Paiva Rodolfo Dias Thulio Philipe
@denniscalazans @leonardopaiva @rmdias @thulioph

What is it?

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

Examples

SSP Usage

Call the SSP file

  <script src="js/SSP.js"></script>

Creating a SSP Module

// SSP.MyModule.js

SSP.MyModule = {
  setUp: function() {
    console.debug('My SSP module is runing!');
  }
}

Creating a SSP Child Module

// SSP.MyModule.Child.js

SSP.MyModule.Child = {
  setUp: function() {
    console.debug('My SSP module is runing!');
  }
}

Incorporating Files

<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>

Available Methods

Properties and Methods

> _namespace


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'
  }
}

> .init( )


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();

> .delegate( scope, method )


Using this method, you can create an anonymous function able to invoke a method inside a determined scope.

SSP.delegate(scope, method);

> .readModule( Module )


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);

> .getByNamespace( 'namespace' )


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}

> .applyByNamespace( 'namespace' )


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');

> .initModuleByNamespace( 'nameSpace' )


Using that method you will run the called module using _namespace.

SSP.initModuleByNamespace('SSP.MyModule');

Contributing

  1. Fork it!
  2. Create your feature branch: git checkout -b my-new-feature
  3. Commit your changes: git commit -m 'Add some feature'
  4. Push to the branch: git push origin my-new-feature
  5. Submit a pull request :D

About

The Simple Singleton Pattern

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published