博文

目前显示的是 三月, 2010的博文

JavaScript Object-Oriented Concept Essential Part2

1. Argument (kinda like polymophism in oop) Every function in Javascript has a private varibale called arugments , which can be used to access all the arguments passed to the function without specifying them as parameters when defiend the function. Ex. function testArg() { for(i =0; i } testArg("argmentnaisni1","ajgajdskgl2"); 2. Prototype 2.1 (kinda like static field of class) prototype is a field of all object, ex, you can use: function Square(){;} // Square.prototype.size = 5;// //then all Square object has a field of size which has value 5. // but one can override prototype filed value, ex function Square(){ this.size = 1; } Square.prototype.size = 5; //because prototytpe loads before the object constructor, so it's // //overrided to 1. 2.2 (use like Inheritance) because prototype is shared by all objects constructed by the function, it can achieve inheritance. Ex. function Car() { this. doors = 4; this. speed = 0; this. brake = function(){this.spe...

JavaScript Object-Oriented Concept Essential Part1

1. Everything excpet primitive types in JavaScript is object. 2. Primitive types include Undefined, Null, Boolean, Number and String. 3. JavaScript has three kinds of objects. 3.1 Build-in objects: Array, Image, Date... 3.2 Host objects: window, document, forms.. 3.3 User-defined. 4. Primitive types has associated object. Ex, var stringObj = new String("create String object"); 5. new is used to create objects. 6. this is used to refer the current object. 7. class in Javascript is defiend as function. class field and function is defined by this . Ex, function Cicle(radius){ this . radius = radius; // defined class field, assigned by parameter of constructor this . getArea = getArea; // defined class function, getArea is a function function getArea(){return this. radius;}// still use this to refer current object //the function getArea can also be defiend outside the class, with this. radius always //refer the object who use the funtio...

Introduction to REST

Building Web Services the REST Way Roger L. Costello I will first provide a brief introduction to REST and then describe how to build Web services in the REST style. What is REST? REST is a term coined by Roy Fielding in his Ph.D. dissertation [1] to describe an architecture style of networked systems. REST is an acronym standing for Representational State Transfer. Why is it called Representational State Transfer? The Web is comprised of resources. A resource is any item of interest. For example, the Boeing Aircraft Corp may define a 747 resource. Clients may access that resource with this URL: http://www.boeing.com/aircraft/747 A representation of the resource is returned (e.g., Boeing747.html). The representation places the client application in a state . The result of the client traversing a hyperlink in Boeing747.html is another resource is accessed....