Lazy Inheritance

Lazy Inheritance

Lazy inheritance is a design pattern used in JavaScript computer programming.

It designates a postponed linking of an object with its prototype (class) until it is needed. If used properly, such approach may increase efficiency, simplicity and flexibility of OOP-based code written using JavaScript.

Since lazy inheritance called only once at the moment of first object instance creation, it seems logical to combine process of class prototype creation with resolving necessary dependencies of that class.

The instances of objects in lazy inheritance are created in "mixed" mode — on first invocation, a factory is used to modify class prototype which is later is used for subsequent object instances creation. In other words, the process of prototype construction also allows loading scripts (if ones were not loaded before) which particular class depends on.

Such approach to inheritance support has the following benefits:
*Lazy inheritance has the same benefits as classical JavaScript prototype features;
* It is not necessary to maintain proper order of script files declaration;
* In most cases, HTML page which contains JavaScript is loaded faster since there are no objects created during page initialization and since some scripts could be loaded only at the moment in which they are actually necessary (they are necessary if the caller code during its execution really creates instances of corresponding classes);
* Dependencies are declared in more explicit way and class depends only on concrete scripts; Moreover, it's not necessary to artificially group particular scripts into modules and define dependencies between such modules;
* If lazy mode of scripts loading is used, only necessary scripts (which are actually required for application functionality) will be loaded. If, for example, some HTML page may operate in different modes, like "read-write" and "read-only", for every mode required scripts will be loaded and this will be performed automatically without manual script loading optimization.

See also

* Lazy loading

Implementation

* [http://www.soft-amis.org/jsiner JSINER' Lazy inheritance implementation]
* [http://sourceforge.net/projects/jsiner JSINER' page on SourceForge]


Wikimedia Foundation. 2010.

Игры ⚽ Поможем сделать НИР

Look at other dictionaries:

  • Lazy loading — is a design pattern commonly used in computer programming to defer initialization of an object until the point at which it is needed. It can contribute to efficiency in the program s operation if properly and appropriately used. The opposite of… …   Wikipedia

  • Lazy initialization — In computer programming, lazy initialization is the tactic of delaying the creation of an object, the calculation of a value, or some other expensive process until the first time it is needed. This is typically accomplished by maintaining a flag… …   Wikipedia

  • Rate-monotonic scheduling — In computer science, rate monotonic scheduling [citation|first1=C. L.|last1=Liu|authorlink1=Chung Laung Liu|first2=J.|last2=Layland|title=Scheduling algorithms for multiprogramming in a hard real time environment|journal=Journal of the ACM|volume …   Wikipedia

  • Python syntax and semantics — The syntax of the Python programming language is the set of rules that defines how a Python program will be written and interpreted (by both the runtime system and by human readers). Python was designed to be a highly readable language. It aims… …   Wikipedia

  • Frederic Remington — Infobox Artist bgcolour = name = Frederic Sackrider Remington imagesize = 200px caption = Frederic S. Remington birthname = Frederic Sackrider Remington birthdate = October 4, 1861 location = Canton, New York deathdate = death date and… …   Wikipedia

  • Thunk — The word thunk has at least three related meanings in computer science. A thunk may be: * a piece of code to perform a delayed computation (similar to a closure) * a feature of some virtual function table implementations (similar to a wrapper… …   Wikipedia

  • Perl 6 — Infobox programming language name = Perl paradigm = Multi paradigm year = 2000 designer = Larry Wall latest release version = pre release latest release date = typing = dynamic, static influenced by = Perl 5, Haskell, Smalltalk influenced =… …   Wikipedia

  • biblical literature — Introduction       four bodies of written works: the Old Testament writings according to the Hebrew canon; intertestamental works, including the Old Testament Apocrypha; the New Testament writings; and the New Testament Apocrypha.       The Old… …   Universalium

  • D (programming language) — For other programming languages named D, see D (disambiguation)#Computing. D programming language Paradigm(s) multi paradigm: imperative, object oriented, functional, meta Appeared in 1999 (1999) Designed by …   Wikipedia

  • Our Mutual Friend —   Cover …   Wikipedia

Share the article and excerpts

Direct link
Do a right-click on the link above
and select “Copy Link”