CSCI N341: Client-Side Web Programming Copyright ©2004  Department of Computer & Information Science "Object-Oriented" JavaScript.

Slides:



Advertisements
Similar presentations
Understand and appreciate Object Oriented Programming (OOP) Objects are self-contained modules or subroutines that contain data as well as the functions.
Advertisements

By Waqas Over the many years the people have studied software-development approaches to figure out which approaches are quickest, cheapest, most.
When is Orientated Programming NOT? Mike Fitzpatrick.
1 OBJECT-ORIENTED CONCEPTS. 2 What is an object?  An object is a software entity that mirrors the real world in some way.  A software object in OOP.
Systems Analysis and Design 8th Edition
OBJECT ORIENTED PROGRAMMING M Taimoor Khan
Fall 2006AE6382 Design Computing1 Object Oriented Programming in Matlab Intro to Object- Oriented Programming (OOP) An example that creates a ASSET class.
Classes and Object- Oriented... tMyn1 Classes and Object-Oriented Programming The essence of object-oriented programming is that you write programs in.
Object Oriented System Development with VB .NET
Basic OOP Concepts and Terms
Computers: Tools for an Information Age
Object-oriented Programming Concepts
ASP.NET Programming with C# and SQL Server First Edition
Chapter 13: Object-Oriented Programming
1 An Introduction to Visual Basic Objectives Explain the history of programming languages Define the terminology used in object-oriented programming.
OBJECT ORIENTED PROGRAMMING IN C++ LECTURE
CSCI N201: Programming Concepts Copyright ©2005  Department of Computer & Information Science Introducing Object-Oriented Programming (OOP)
1 INTRODUCTION TO OOP Objective: Know the difference between functional programming and OOP Know basic terminology in OOP Know the importance of OOP Know.
Programming Paradigms Imperative programming Functional programming Logic programming Event-driven programming Object-oriented programming A programming.
Object Oriented Programming
CH1 – A 1 st Program Using C#. Program Set of instructions which tell a computer what to do. Machine Language Basic language computers use to control.
1 INTRODUCTION TO OOP Objective: Know the difference between functional programming and OOP Know basic terminology in OOP Know the importance of OOP Know.
Object Oriented Software Development
A First Program Using C#
Microsoft Visual Basic 2005: Reloaded Second Edition
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Extended Prelude to Programming Concepts & Design, 3/e by Stewart Venit and.
Extended Prelude to Programming Concepts & Design, 3/e by Stewart Venit and Elizabeth Drake Chapter 8: More About OOP and GUIs.
An Object-Oriented Approach to Programming Logic and Design
Sadegh Aliakbary Sharif University of Technology Fall 2011.
BIT 1003 – Presentation 7. Contents GENERATIONS OF LANGUAGES COMPILERS AND INTERPRETERS VIRTUAL MACHINES OBJECT-ORIENTED PROGRAMMING SCRIPTING LANGUAGES.
Enhancing JavaScript Using Application Programming Interfaces (APIs)
JavaScript, Fourth Edition
Chapter 6 Object-Oriented Java Script JavaScript, Third Edition.
Systems Analysis & Design 7 th Edition Chapter 5.
Systems Analysis and Design 8 th Edition Chapter 6 Object Modeling.
SNPL1 Woochang Lim What (Variable) + How (Function) = Object Objects are the physical and conceptual things we find in the universe around us. Object-Oriented.
Basic OOP Concepts and Terms. In this class, we will cover: Objects and examples of different object types Classes and how they relate to objects Object.
Principles of Software Development 1 Principles Of Software Design and Development Types of language / Choosing a language.
Introducing JavaScript. Goals By the end of this lecture you should … Be able to describe the differences among object methods, object properties and.
Learners Support Publications Object Oriented Programming.
Abstraction ADTs, Information Hiding and Encapsulation.
1.
Programming with Java © 2002 The McGraw-Hill Companies, Inc. All rights reserved. 1 McGraw-Hill/Irwin Chapter 5 Creating Classes.
Salman Marvasti Sharif University of Technology Winter 2015.
Visual Basic for Application - Microsoft Access 2003 Programming applications using Objects.
Addison Wesley is an imprint of © 2010 Pearson Addison-Wesley. All rights reserved. Chapter 12 Object-Oriented Programming Starting Out with Games & Graphics.
Introduction into JavaScript Java 1 JavaScript JavaScript programs run from within an HTML document The statements that make up a program in an HTML.
Chapter 4 Basic Object-Oriented Concepts. Chapter 4 Objectives Class vs. Object Attributes of a class Object relationships Class Methods (Operations)
Copyright © 2010 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with Programming Logic & Design Second Edition by Tony Gaddis.
OO in Context Lecture 13: Dolores Zage. Confused about OO Not alone, there is much confusion about OO many programs are claimed to be OO but are not really.
Lesson 1 1 LESSON 1 l Background information l Introduction to Java Introduction and a Taste of Java.
Learning OOP in PHP. What is OOP? OOP stands for Object Oriented Programming. OOP is a programming paradigm wherein you create “objects” to work with.
Copyright ©2005  Department of Computer & Information Science Object Based JavaScript.
Copyright © 2010 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with Programming Logic & Design Second Edition by Tony Gaddis.
CSCI N341: Client-Side Web Programming Copyright ©2004  Department of Computer & Information Science Introducing JavaScript.
Sadegh Aliakbary Sharif University of Technology Fall 2010.
 By the end of this lecture, you should …  Understand the three pillars of Object- Oriented Programming: Inheritance, Encapsulation and Polymorphism.
Copyright ©2005  Department of Computer & Information Science Object Oriented Concepts.
Object-oriented programming (OOP) is a programming paradigm using "objects" – data structures consisting of data fields and methods together with their.
 The Object Oriented concepts was evolved for solving complex problems. Object- oriented software development started in the 1980s. Object-oriented design.
Programming paradigms
JAVA By Waqas.
Chapter 8: More About OOP and GUIs
PRINCIPALES OF OBJECT ORIENTED PROGRAMMING
Computer Programming.
Basic OOP Concepts and Terms
Introducing JavaScript
Object Oriented Programming (OOP)- Assist. Prof. Dr
Presentation transcript:

CSCI N341: Client-Side Web Programming Copyright ©2004  Department of Computer & Information Science "Object-Oriented" JavaScript

CSCI N341: Client-Side Web Programming Copyright ©2004  Department of Computer & Information Science Goals Review what objects areReview what objects are Understand InheritanceUnderstand Inheritance Understand EncapsulationUnderstand Encapsulation Understand PolymorphismUnderstand Polymorphism Define a JavaScript ObjectDefine a JavaScript Object

CSCI N341: Client-Side Web Programming Copyright ©2004  Department of Computer & Information Science REVIEW: Objects An object is a unique programming entity in a script and/or web page. An object has properties that describe it, methods which it can perform and events to which it can react.An object is a unique programming entity in a script and/or web page. An object has properties that describe it, methods which it can perform and events to which it can react.

CSCI N341: Client-Side Web Programming Copyright ©2004  Department of Computer & Information Science REVIEW: Properties A property (aka – "attribute") is a characteristic that describes an object. It is similar to an adjective in grammar. Properties are given values (Hair Color is a property; its value might be brown or red).A property (aka – "attribute") is a characteristic that describes an object. It is similar to an adjective in grammar. Properties are given values (Hair Color is a property; its value might be brown or red).

CSCI N341: Client-Side Web Programming Copyright ©2004  Department of Computer & Information Science REVIEW: Methods A method is something an object can do. It is similar to a verb in grammar. Sometimes we need to give methods descriptive words that tell it how to work. These descriptive words are called arguments (Running might be a method of the “human object”; an argument for running might be the speed at which to run).A method is something an object can do. It is similar to a verb in grammar. Sometimes we need to give methods descriptive words that tell it how to work. These descriptive words are called arguments (Running might be a method of the “human object”; an argument for running might be the speed at which to run).

CSCI N341: Client-Side Web Programming Copyright ©2004  Department of Computer & Information Science REVIEW: Events An event is something in an object’s environment to which that object can react. For the human object, a fire alarm is an event; Humans react to a fire alarm using a method – exiting the building.An event is something in an object’s environment to which that object can react. For the human object, a fire alarm is an event; Humans react to a fire alarm using a method – exiting the building.

CSCI N341: Client-Side Web Programming Copyright ©2004  Department of Computer & Information Science Inheritance Inheritance — The ability to create new classes that are based on existing ones. The methods (operations) and attributes (data) of the original class are usually incorporated into the new class, together with methods and attributes specific to the latter.Inheritance — The ability to create new classes that are based on existing ones. The methods (operations) and attributes (data) of the original class are usually incorporated into the new class, together with methods and attributes specific to the latter. These pre-defined blueprints already know how to perform many methods, and come with a framework for accompanying attributes.These pre-defined blueprints already know how to perform many methods, and come with a framework for accompanying attributes. For example, in Java there is a button class, which has an attribute of a label, and can perform certain tasks when clicked.For example, in Java there is a button class, which has an attribute of a label, and can perform certain tasks when clicked.

CSCI N341: Client-Side Web Programming Copyright ©2004  Department of Computer & Information Science Encapsulation Encapsulation is incorporation of data and operations on that data into a single unit in such a way that the data can only be accessed through these operations. This is the fundamental idea behind classes and objects. Also referred to as data hiding, traces its history to subroutines and functionsEncapsulation is incorporation of data and operations on that data into a single unit in such a way that the data can only be accessed through these operations. This is the fundamental idea behind classes and objects. Also referred to as data hiding, traces its history to subroutines and functions

CSCI N341: Client-Side Web Programming Copyright ©2004  Department of Computer & Information Science More on Encapsulation If one object passes a message to another, asking that a method be performed, the calling object doesn’t need to know the gory details of how the task was performed… it simply needs a final result back from the called objectIf one object passes a message to another, asking that a method be performed, the calling object doesn’t need to know the gory details of how the task was performed… it simply needs a final result back from the called object The called object is using encapsulation… its method detail and attribute values can remain hidden from view – and thereby protected.The called object is using encapsulation… its method detail and attribute values can remain hidden from view – and thereby protected. Encapsulation adds some built in quality control to programming by restricting access to variables and blocks of code and by forcing programmers to think in terms of small, focused subsections of code.Encapsulation adds some built in quality control to programming by restricting access to variables and blocks of code and by forcing programmers to think in terms of small, focused subsections of code.

CSCI N341: Client-Side Web Programming Copyright ©2004  Department of Computer & Information Science Polymorphism Polymorphism — The ability to create methods that perform a general function, which automatically adapts itself to work with objects of different classes.Polymorphism — The ability to create methods that perform a general function, which automatically adapts itself to work with objects of different classes. To design code supporting polymorphism, it means that you develop your code in general enough terms that it supports application in other ways.To design code supporting polymorphism, it means that you develop your code in general enough terms that it supports application in other ways. For example, imagine writing a close method for a door object. If you were thoughtful enough in the design, the same method could be utilized by a window object, or maybe even a mouth object!For example, imagine writing a close method for a door object. If you were thoughtful enough in the design, the same method could be utilized by a window object, or maybe even a mouth object!

CSCI N341: Client-Side Web Programming Copyright ©2004  Department of Computer & Information Science Is JavaScript an OOP language? Well, not really …Well, not really … We call JavaScript an "object-inspired" languageWe call JavaScript an "object-inspired" language It uses objects by way of supporting inheritance and encapsulation, but it doesn't really provide support for polymorphism.It uses objects by way of supporting inheritance and encapsulation, but it doesn't really provide support for polymorphism.

CSCI N341: Client-Side Web Programming Copyright ©2004  Department of Computer & Information Science “Object-Oriented” JavaScript More like “Object-Inspired” JavaScriptMore like “Object-Inspired” 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.”

CSCI N341: Client-Side Web Programming Copyright ©2004  Department of Computer & Information Science Solution without OOP Design Uses parallel arraysUses parallel arrays Can be confusingCan be confusing –Difficult to keep track of which car has which color, brand, etc. Example:Example:

CSCI N341: Client-Side Web Programming Copyright ©2004  Department of Computer & Information Science Solution with OOP Design Calls to an API that contains the custom car objectCalls to an API that contains the custom car object Much cleaner codeMuch cleaner code Re-usable objectRe-usable object

CSCI N341: Client-Side Web Programming Copyright ©2004  Department of Computer & Information Science What is an API? API stands for Application Programming InterfaceAPI stands for Application Programming Interface Allows programmers to extend the current language to included customized componentsAllows programmers to extend the current language to included customized components Most modern languages incorporate APIsMost modern languages incorporate APIs

CSCI N341: Client-Side Web Programming Copyright ©2004  Department of Computer & Information Science Questions?