Alternative Lazy JavaScript Inheritance
hide
ContentsLazy Inheritance is an approach intended to simplify writing OOP and provides support of prototype-based classes hierarhies, automatic resolving and optimizing classes dependencies. Overview"Lazy inheritance" is a design pattern used in JavaScript computer programming. It designates a postponed linking of an object with it's prototype (class) until it is needed. If used properly, such approach may increase efficiency, simplicity and flexibility of OOP based code written using JavaScript. Unlike of classical prototype-based approach, it supports a "Lazy" way of inheritance implementation, since reference to parent class is invoked only at the moment of object instance creation. BenefitsSuch approach to inheritance support has the following benefits:
Lazy Inheritance Internals"Lazy inheritance" is invoked within the Object' constructor code and is called only once for first object instance creation.After invocation, the following steps:
The derived instance of the Object may be modified in the constructor according to particular logic. For example, some properties of the object may be defined. ExampleFirst, we define Person.
Here we assume that the code below is placed to employee.js file.
And this is sample HTML page which uses declarations of JavaScript object above:
During execution of example code listed above, linkage of Employee and Person as well as
In general, the proposed scheme considers "lazy" loading as primary mode for loading particular scripts. However, this is not strict requirement – it is also possible to force loading of all scripts which form particular application before starting objects creation if this way of loading is required by particular application architecture. Where it worksProposed Lazy inheritance approach was tested under
Lazy Inheritance Implementation
|
navigation
Download
Community
Weblog
Mailing Lists
IRC Channel
Documentation
Introductions
Tools
Reference
Project
Roadmap
Bug Reporting
Source
Helma NG Wiki
Wiki
Tags
Updates
Related Projects
Sites using Helma
Shop
search
tags for this page
all tags
Tagsapps (1) bugs (2) class (1) community (2) compatibility (1) concurrency (1) continuations (2) Documentation (6) dogfood (1) formatting (1) functions (1) gobi (1) helma (7) helma 1.6 (13) helma 1.7 (8) helma 1.x (1) helma 2 (11) helma ng (20) hopobject (1) howto sample code xml-rpc (1) html (1) inheritance (5) introspection (1) java (3) javascript (5) jetty (1) JSDoc (1) lazy (1) marius person (1) metaprogramming (3) modules (5) oop (1) organization (2) ORM (2) parsing (1) plugins (1) project (2) projects (1) prototype (2) prototype scope rhino functions this (0) Rabbit (2) Reference (1) REPL (1) rhino (5) roadmap (3) scope (1) shell (1) shop (0) Skin Rendering (5) Snippets (1) source svn (1) sugar (3) templates (13) testing (5) this (1) Tobi (7) xml (1) Pages linking to this page: Wiki Overview Text Draft, wiki |