Joose (framework)
Encyclopedia
Joose is an open-source self-hosting meta object system
Metaprogramming
Metaprogramming is the writing of computer programs that write or manipulate other programs as their data, or that do part of the work at compile time that would otherwise be done at runtime...

 for JavaScript
JavaScript
JavaScript is a prototype-based scripting language that is dynamic, weakly typed and has first-class functions. It is a multi-paradigm language, supporting object-oriented, imperative, and functional programming styles....

 with support for classes
Class (computer science)
In object-oriented programming, a class is a construct that is used as a blueprint to create instances of itself – referred to as class instances, class objects, instance objects or simply objects. A class defines constituent members which enable these class instances to have state and behavior...

, inheritance
Inheritance (computer science)
In object-oriented programming , inheritance is a way to reuse code of existing objects, establish a subtype from an existing object, or both, depending upon programming language support...

, mixin
Mixin
In object-oriented programming languages, a mixin is a class that provides a certain functionality to be inherited or just reused by a subclass, while not meant for instantiation , Mixins are synonymous functionally with abstract base classes...

s, traits and aspect oriented programming.

The Joose meta-object system is multi-paradigm. It supports class-based
Class-based programming
Class-based programming, or more commonly class-orientation, refers to the style of object-oriented programming in which inheritance is achieved by defining classes of objects, as opposed to the objects themselves .The most popular and developed model of OOP is a class-based model, as opposed to an...

 and prototype-based
Prototype-based programming
Prototype-based programming is a style of object-oriented programming in which classes are not present, and behavior reuse is performed via a process of cloning existing objects that serve as prototypes. This model can also be known as classless, prototype-oriented or instance-based programming...

 programming styles as well as class-based inheritance and role-based extension. While other JavaScript frameworks often specialize on DOM
Document Object Model
The Document Object Model is a cross-platform and language-independent convention for representing and interacting with objects in HTML, XHTML and XML documents. Aspects of the DOM may be addressed and manipulated within the syntax of the programming language in use...

-access and AJAX
Ajax (programming)
Ajax is a group of interrelated web development methods used on the client-side to create asynchronous web applications...

, Joose specializes solely on bringing successul programming techniques to the JavaScript scripting language. Joose is thus often used in conjunction with another DOM/Ajax JavaScript framework and is tested with jQuery
JQuery
jQuery is a cross-browser JavaScript library designed to simplify the client-side scripting of HTML. It was released in January 2006 at BarCamp NYC by John Resig...

, YUI
YUI
, stylized as YUI, is a multi-instrumentalist, singer-songwriter, composer, actress, and radio personality. Born and raised in Fukuoka, she played live at various locations in her home town before being noticed by Sony Music Japan when she was 17 and released her debut single months later...

, Dojo
Dojo
A is a Japanese term which literally means "place of the way". Initially, dōjōs were adjunct to temples. The term can refer to a formal training place for any of the Japanese do arts but typically it is considered the formal gathering place for students of any Japanese martial arts style to...

, ExtJS, Prototype
Prototype
A prototype is an early sample or model built to test a concept or process or to act as a thing to be replicated or learned from.The word prototype derives from the Greek πρωτότυπον , "primitive form", neutral of πρωτότυπος , "original, primitive", from πρῶτος , "first" and τύπος ,...

, Mootools
MooTools
MooTools is a lightweight, object-oriented, web-application framework for JavaScript, written in JavaScript. It is released under the free, open-source MIT License...

 and PureMVC
PureMVC
PureMVC is a framework for creating applications based upon the well-established Model, View and Controller design pattern. The free, open source framework was originally implemented in the ActionScript 3 language for use with Adobe Flex, Flash and AIR, and it has since been ported to nearly all...

.

Joose was heavily inspired by Moose
Moose (Perl)
Moose is an extension of the Perl 5 object system. It brings modern object-oriented language features to Perl 5, making object-oriented programming more consistent and less tedious.-Features:...

, the object system for Perl 5
Perl
Perl is a high-level, general-purpose, interpreted, dynamic programming language. Perl was originally developed by Larry Wall in 1987 as a general-purpose Unix scripting language to make report processing easier. Since then, it has undergone many changes and revisions and become widely popular...

 which was itself inspired by Perl 6
Perl 6
Perl 6 is a major revision to the Perl programming language. It is still in development, as a specification from which several interpreter and compiler implementations are being written. It is introducing elements of many modern and historical languages. Perl 6 is intended to have many...

 object system, but unlike Perl and Moose, Joose doesn't support multiple inheritance
Multiple inheritance
Multiple inheritance is a feature of some object-oriented computer programming languages in which a class can inherit behaviors and features from more than one superclass....

.

Example

Two classes written in Joose:


Class("Point", {
has: {
x: {is: "rw"},
y: {is: "rw"}
},
methods: {
clear: function {
this.setX(0);
this.setY(0);
}
}
});

Class("Point3D", {
isa: Point,
has: {
z: {is: "rw"}
},
after: {
clear: function {
this.setZ(0);
}
}
});


Point3D is a subclass of Point. It has another attribute defined and additional code to run after running the superclass clear method. The "rw" means the attribute is readable and writable with a pair of get/set accessors generated automatically.

External links

The source of this article is wikipedia, the free encyclopedia.  The text of this article is licensed under the GFDL.
 
x
OK