How does Pattern Object Linked to Other Objects work?

Asked

Viewed 47 times

3

What is Pattern OLOO? How does it work? What is its difference to Prototype Pattern? What is the advantage of using each one?

1 answer

1

The OLOO pattern creates string prototype without the need to intermediate other semantics (e.g.. prototype, new, function) to create and link objects, making it simpler than the Prototype standard.

OLOO differs from Prototype essentially in syntax (form of construction of objects and linkage between them):

See 2 examples in each pattern in the construction of prototype:

Prototype Pattern:

function Abc() {}
Abc.prototype.y = 1;

OLOO Pattern:

var AbcObj = { y: 1 };

Note that in OLOO the syntax is simpler and more direct, without semantic intermediation prototype and function.


Now examples of how each pattern binds one object to another:

Prototype Pattern:

function Abc() {}

function Tst() {}
Tst.prototype = Object.create(Abc.prototype);

or

function Abc() {}

var Tst = new Abc();

OLOO Pattern:

var AbcObj = {};

var TstObj = Object.create(AbcObj);

Note that in OLOO just create a variable (var TstObj) and link directly to the other object (AbcObj) using Object.create(), without the need for other semantics, such as prototype, new and function.


Completion:

One cannot define the "advantage of each", because the two patterns produce the same result, however, the OLOO standard is much simpler than the Prototype standard for having a "leaner" syntax, creating and binding objects directly and saving semantics. In this concept, the use of the OLOO standard becomes more advantageous than the Prototype standard.

The material on this page provides some information about the OLOO standard.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.