OOP in JavaScript

Loading...

Flash Player 9 (or above) is needed to view presentations.
We have detected that you do not have it on your computer. To install it, go here.

0 comments

Post a comment

    Post a comment
    Embed Video
    Edit your comment Cancel

    10 Favorites & 1 Group

    OOP in JavaScript - Presentation Transcript

    1. OOP in JavaScript “ The World's Most Misunderstood Programming Language” Douglas Crockford
    2. Some Myths
      • JavaScript is related to Java
      • JavaScript was developed by Sun Microsystems
      • JavaScript is not Object Oriented
      • JavaScript does not support data hiding, i.e. everything is public
    3. OOP Concepts
      • Encapsulation
      • Inheritance
      • Polymorphism
    4. Encapsulation
      • Definition
        • Data + Operation
        • Single logically organized unit
        • Data visibility
    5. Inheritance
      • Definition
        • Parent-child relationship between classes
        • Child inherits Parents’ characteristics
        • Child can redefine existing characteristics
        • Child can add more characteristics
    6. Polymorphism
      • Definition
        • Multiple functions
        • Share a common name
        • Context specific invocation
      • The characteristic of being able to assign a different meaning or usage to something in different contexts ( http://searchsmb.techtarget.com/sDefinition/0,,sid44_gci212803,00.html )
    7. Encapsulation
      • Private variables - Can only be accessed by private functions and privileged methods
      • Private functions - Can only be called by privileged methods
      • Privileged methods - May invoked by code external to the object
      • Public properties - May be read/written from outside the object
      • Public methods - Shared methods
      • Prototype properties - Shared properties
    8. Encapsulation
      • function Student(name)
      • {
      • var age = 0;
      • var checkAge = function(){ return (age > 0) ? age : false; };
      • this.getAge = function(){
      • return (checkAge()) ? age : “Age not set”;
      • }
      • this.setAge = function(_age){ age = _age; }
      • this.name = name;
      • this.constructor.prototype.updateTotal();
      • }
      • Student.prototype.total = 0;
      • Student.prototype.updateTotal = function(){
      • this.constructor.prototype.total++;
      • }
    9. Inheritance
      • See Listing 1
      • See Listing 2
    10. Polymorphism
      • See Listing 1
    11. What more?
      • JSON
      • Closures
    12. JSON
      • Object – { }
      • Array – [ ]
      • Separator – , :
      • Var students = [
      • {name : “abc” , age : 20} ,
      • {name : “xyz” , age : 21}
      • ];
    13. References
      • http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference
      • http://mckoss.com/jscript/object.htm
      • http://www.sitepoint.com/article/oriented-programming-1
      • http://www.codeproject.com/aspnet/JsOOP1.asp
      • http://phrogz.net/JS/Classes/OOPinJS.html
      • http://javascript.crockford.com/javascript.html
      • http://kevlindev.com/tutorials/javascript/inheritance/index.htm
      • http://www.dustindiaz.com/javascript-private-public-privileged/
      • http://developer.yahoo.com/yui/theater/
      • http://www.dustindiaz.com/json-for-the-masses/
      • http:// www.json.org /
      • Google + Wikipedia = Many Many more references

    + manugoel2003manugoel2003, 3 years ago

    custom

    2662 views, 10 favs, 0 embeds more stats

    Manu - OOP in JavaScript

    More info about this document

    © All Rights Reserved

    Go to text version

    • Total Views 2662
      • 2662 on SlideShare
      • 0 from embeds
    • Comments 0
    • Favorites 10
    • Downloads 212
    Most viewed embeds

    more

    All embeds

    less

    Flagged as inappropriate Flag as inappropriate
    Flag as inappropriate

    Select your reason for flagging this presentation as inappropriate. If needed, use the feedback form to let us know more details.

    Cancel
    File a copyright complaint
    Having problems? Go to our helpdesk?

    Categories

    Groups / Events