The Simple Singleton Pattern
JavaScript CSS HTML
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.

The Simple Singleton Pattern

The Simple Singleton Pattern - A solution to many problems


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


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>

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;
    // return -> 'SSP.MyModule'

> .init( )

This method initializes all modules from your application.


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

### > .setUp( )

SetUp is a Main method. It always runs when the father's module is called.


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


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


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:


> .initModuleByNamespace( 'nameSpace' )

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



  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