Presentation is loading. Please wait.

Presentation is loading. Please wait.

Copyright ©2005  Department of Computer & Information Science Object Based JavaScript.

Similar presentations


Presentation on theme: "Copyright ©2005  Department of Computer & Information Science Object Based JavaScript."— Presentation transcript:

1 Copyright ©2005  Department of Computer & Information Science Object Based JavaScript

2 Copyright ©2005  Department of Computer & Information Science Goals By the end of this lecture you should …

3 Copyright ©2005  Department of Computer & Information Science REVIEW: What is an object? An object is a unique programming entity that has attributes to describe it and methods to retrieve/set attribute values.An object is a unique programming entity that has attributes to describe it and methods to retrieve/set attribute values. We can create a blueprint of an object called a class.We can create a blueprint of an object called a class. We can create a usable instance of a class through instantiation.We can create a usable instance of a class through instantiation.

4 Copyright ©2005  Department of Computer & Information Science REVIEW: Encapsulation Data and the ways to get at that data are wrapped in a single package, a class. The only way to access such data is through that package. This idea translates to information hiding.Data and the ways to get at that data are wrapped in a single package, a class. The only way to access such data is through that package. This idea translates to information hiding.

5 Copyright ©2005  Department of Computer & Information Science REVIEW: Inheritance Inheritance allows programmers to create new classes from existing ones.Inheritance allows programmers to create new classes from existing ones. A child class inherits its properties and attributes from its parents, which programmers can change.A child class inherits its properties and attributes from its parents, which programmers can change.

6 Copyright ©2005  Department of Computer & Information Science REVIEW: Polymorphism Polymorphism describes how programmers write methods to do some general purpose function.Polymorphism describes how programmers write methods to do some general purpose function. Different objects might perform polymorphic methods differently.Different objects might perform polymorphic methods differently.

7 Copyright ©2005  Department of Computer & Information Science Is JavaScript “Object-Oriented?” Well, not really. We’ll call it “Object- Based” instead …Well, not really. We’ll call it “Object- Based” instead … JavaScript uses objects by way of supporting inheritance and encapsulation, but it doesn't really provide support for polymorphism.JavaScript uses objects by way of supporting inheritance and encapsulation, but it doesn't really provide support for polymorphism.

8 Copyright ©2005  Department of Computer & Information Science Object-Based JavaScript We can create new, custom, re-usable objects in JavaScript that include their own methods, properties and events.We can create new, custom, re-usable objects in JavaScript that include their own methods, properties and events. Consider the following problem: “I want to record the color, brand, horsepower and price of several cars.”Consider the following problem: “I want to record the color, brand, horsepower and price of several cars.”

9 Copyright ©2005  Department of Computer & Information Science Solution Without Objects One solution to our problem is to rely on parallel arrays.One solution to our problem is to rely on parallel arrays. However this can be confusing, as it can be difficult to track with attribute belongs to which car …However this can be confusing, as it can be difficult to track with attribute belongs to which car …

10 Copyright ©2005  Department of Computer & Information Science Open the file called objectBasedProg_01.html

11 Copyright ©2005  Department of Computer & Information Science What is an API? API stands for Application Programming Interface.API stands for Application Programming Interface. APIs allow programmers to extend the current language to included customized, re-usable components.APIs allow programmers to extend the current language to included customized, re-usable components. Most modern languages incorporate APIs.Most modern languages incorporate APIs.

12 Copyright ©2005  Department of Computer & Information Science Open the files called objectBasedProg_02.html & carLib.js

13 Copyright ©2005  Department of Computer & Information Science Summary


Download ppt "Copyright ©2005  Department of Computer & Information Science Object Based JavaScript."

Similar presentations


Ads by Google