Object Oriented JavaScript: Modular development

In my previous article i talked about the fundamental concepts of object oriented programming, abstraction, encapsulation, inheritance and polymorphism. These concepts are a part of developing object oriented code and if structured appropriately can be used to create highly modular reusable code.

Developing reusable code is a necessity of software development, it allows for a more efficient development cycle and continuous improvement of an existing development.

The alternative to code reuse is code salvage. Code salvage is an inefficient method of stripping the code down for it’s useful parts and discarding the rest. In creating modular code we hope to support code reuse by making all of the code module useful.

To create modular code we need to look at the key characteristics of a module. For that i am going to reference Bertrand Meyer’s [1] [2] five criteria for modular development from his book Object-Oriented Software Construction.[3] [4]

The scale of modularity for each of the criteria may vary per module but by using these criteria to guide development of modules we should be able to create discrete, understandable and robust modules that can be used as building blocks for projects.

We can assess the affect of leveraging these principles by understanding two artefacts of code development, coupling and cohesion.

Modular code should have low coupling and high cohesion. The lower the coupling, the less reliance the module has on external factors to function, this increases the chance that the module can be reused. Higher cohesion also increases the likelihood that a module can be reused, as it’s boundary is better defined making it easier to extract.


By using object oriented programming to create modular code we are trying to create code that we can reuse across projects. JavaScript libraries and the plugins they support are great examples of modular reusable code and in using these libraries we can focus on increasingly complex problems rather than reiterate the fundamentals like cross browser classname selection.

Nanos gigantium humeris insidentes [5] – By creating, sharing and using modular code we may all stand on the shoulders of giants.


  1. http://se.ethz.ch/~meyer/. Retrieved 17/07/2011.
  2. http://en.wikipedia.org/wiki/Bertrand_Meyer. Retrieved 17/07/2011.
  3. http://www.amazon.co.uk/Object-Oriented-Software-Construction-Prentice-Hall-Resource/dp/0136291554/. Retrieved 17/07/2011.
  4. http://en.wikipedia.org/wiki/Object-Oriented_Software_Construction. Retrieved 17/07/2011.
  5. http://en.wikipedia.org/wiki/Standing_on_the_shoulders_of_giants. Retrieved 17/07/2011.
Comment on Object Oriented JavaScript: Modular development

Your email address will not be published.

You may use these HTMLtags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>