Object JavaScript – Revealing Modular Pattern Into Asynchronous Modules

image6[1]Let’s put our revealing module pattern into asynchronous modules definition (AMD).

Asynchronous module definition (AMD) is a JavaScript API for defining modules such that the module and its dependencies can be asynchronously loaded. It is useful in improving the performance of websites by bypassing synchronous loading of modules along with the rest of the site content.

modular, we generally mean it’s composed of a set of highly decoupled, distinct pieces of functionality stored in modules. As you probably know, loose coupling facilitates easier maintainability of apps by removing dependencies where possible.

Loose coupling implies each component can operate or be tested independently of other components.

Tight coupling implies each component “knows” the details or inner workings of other components.

In just a few lines of code you can provide for architectural features above to improve from revealing module pattern to asynchornous module definition code. Here’s a look into why and how.

Continue reading “Object JavaScript – Revealing Modular Pattern Into Asynchronous Modules”

Object JavaScript – Asynchronous Module Definition (AMD)

10063_580983808600819_401360548_nIn the last few posts we showed how you can create objects in JavaScript. You can define public and private functions, methods, properties in your objects.

But what about dependencies? As we write more and more complex applications, our objects rely on other objects. There becomes a hierarchy. And if that hierarchy is not respected, if one object is run before the object that it requires is loaded, there’s problems.

Developers want to write discrete JS files and modules. We need some sort of #include/import/require. we need the ability to load nested dependencies.

And we want to be able to load our objects asynchronously.

Continue reading “Object JavaScript – Asynchronous Module Definition (AMD)”