INTRODUCTION TO JAVASCRIPT OBJECTS

Similar documents
Custom Fonts / Setting up a Domain

Duet Enterprise: Tracing Reports in SAP, SCL, and SharePoint

MYSQL DATABASE ACCESS WITH PHP

SAP AddOn Quantity Distribution. by Oliver Köhler, SAP Germany

Single Sign-on For SAP NetWeaver Mobile PDA Client

SAP NetWeaver Identity Management Identity Center Minimum System Requirements

How to Handle the System Message in SAP NetWeaver Mobile 7.1

EWM125. Labor Management in SAP EWM COURSE OUTLINE. Course Version: 16 Course Duration: 4 Hours

BIT460. SAP Process Integration Message Mapping COURSE OUTLINE. Course Version: 15 Course Duration: 3 Day(s)

Configuring relay server in Sybase Control Center

How to Enable Single Sign-On for Mobile Devices?

SAP BusinessObjects Predictive Analysis 1.0 Supported Platforms

Manual Activities of SAP Note Globalization Services, 2012/06/05

BC100. Introduction to Programming with ABAP COURSE OUTLINE. Course Version: 15 Course Duration: 2 Day(s)

ADM950. Secure SAP System Management COURSE OUTLINE. Course Version: 10 Course Duration: 2 Day(s)

Visual Composer Modeling: Data Validation in the UI

Duplicate Check and Fuzzy Search for Accounts and Contacts. Configuration with SAP NetWeaver Search and Classification (TREX) in SAP CRM WebClient UI

PLM210. Master Data Configuration in SAP Project System COURSE OUTLINE. Course Version: 15 Course Duration: 2 Day(s)

INTRODUCTION TO ABAP PROGRAMMING: SYNTAX FUNDAMENTALS

Enterprise Search Extension for SAP Master Data Governance

AC507. Additional Functions of Product Cost Planning COURSE OUTLINE. Course Version: 15 Course Duration: 2 Day(s)

Quick View Insider Microblog: Why Is There No Inbox?

Crystal Reports 2008 FixPack 2.4 Known Issues and Limitations

How to Find Suitable Enhancements in SAP Standard Applications

BOCE20. SAP Crystal Reports for Enterprise: Advanced Report Design COURSE OUTLINE. Course Version: 15 Course Duration: 3 Day(s)

Visual Composer for SAP NetWeaver Composition Environment - Connectors

How to reuse BRFplus Functions Similar to R/3 Function Modules using BRF+ Expression Type Function Call

DS50. Managing Data Quality with SAP Information Steward COURSE OUTLINE. Course Version: 10 Course Duration: 2 Day(s)

Installing SAP NetWeaver Mobile Client (eswt) on a Storage Card

NET311. Advanced Web Dynpro for ABAP COURSE OUTLINE. Course Version: 10 Course Duration: 4 Day(s)

BOC320. SAP Crystal Reports - Business Reporting and Report Processing Strategies COURSE OUTLINE. Course Version: 15 Course Duration: 3 Day(s)

Visual Composer Modeling: Migrating Models from 7.1.X to 7.2.0

MDG100 Master Data Governance

DEV523 Customizing and Extending PowerDesigner

Quick View Insider: Understanding Quick View Configuration

How to Download Software and Address Directories in SAP Service Marketplace

BC430 ABAP Dictionary

Using JournalEntries and JournalVouchers Objects in SAP Business One 6.5

BC405 Programming ABAP Reports

ADM900 SAP System Security Fundamentals

EDB785 SAP IQ Administration

BOC310. SAP Crystal Reports: Fundamentals of Report Design COURSE OUTLINE. Course Version: 15 Course Duration: 2 Day(s)

BC410. Programming User Dialogs with Classical Screens (Dynpros) COURSE OUTLINE. Course Version: 10 Course Duration: 3 Day(s)

EDB358. System and Database Administration: Adaptive Server Enterprise COURSE OUTLINE. Course Version: 10 Course Duration: 5 Day(s)

ADM950. Secure SAP System Management COURSE OUTLINE. Course Version: 15 Course Duration: 2 Day(s)

SAP BusinessObjects Dashboards 4.0 SAP Crystal Dashboard Design 2011 SAP Crystal Presentation Design 2011

HA150 SQL Basics for SAP HANA

Testing Your New Generated SAP NetWeaver Gateway Service

Visual Composer s Control Types

Quick View Insider: How Can I Change the Colors? (SNC 7.0)

Using Default Values in Backend Adapter

BC480 PDF-Based Print Forms

BC490 ABAP Performance Tuning

TBIT44 PI Mapping and ccbpm

ADM100 AS ABAP - Administration

How to Set Up Data Sources for Crystal Reports Layouts in SAP Business One, Version for SAP HANA

BW Text Variables of Type Replacement Path

BC400 Introduction to the ABAP Workbench

EDB367. Powering Up with SAP Adaptative Server Enterprise 15.7 COURSE OUTLINE. Course Version: 10 Course Duration: 2 Day(s)

ADM960. SAP NetWeaver Application Server Security COURSE OUTLINE. Course Version: 10 Course Duration: 5 Day(s)

SAP Afaria Post- Installation Part 1

BC404. ABAP Programming in Eclipse COURSE OUTLINE. Course Version: 15 Course Duration: 3 Day(s)

GRC100. GRC Principles and Harmonization COURSE OUTLINE. Course Version: 10 Course Duration: 2 Day(s)

BC400. ABAP Workbench Foundations COURSE OUTLINE. Course Version: 15 Course Duration: 5 Day(s)

Message Alerting for SAP NetWeaver PI Advanced Adapter Engine Extended

AFA461 SAP Afaria 7.0 System Administration (SP03)

SAP Plant Connectivity 2.2

Content Management Systems (CMS) Wordpress

BC401. ABAP Objects COURSE OUTLINE. Course Version: 15 Course Duration: 5 Day(s)

Business Objects Integration Scenario 2

EP350. Innovated Content Management and Collaboration COURSE OUTLINE. Course Version: 10 Course Duration: 5 Day(s)

How to Guide to create Sample Application in IOS using SUP ODP 2.2

EDB116. Fast Track to SAP Adaptive Server Enterprise COURSE OUTLINE. Course Version: 15 Course Duration: 5 Day(s)

ADM960. SAP NetWeaver Application Server Security COURSE OUTLINE. Course Version: 15 Course Duration: 5 Day

BW310. BW - Enterprise Data Warehousing COURSE OUTLINE. Course Version: 10 Course Duration: 5 Day(s)

TBW30 SAP BW Modeling & Implementation

ADM920 SAP Identity Management

How to Check or Derive an Attribute Value in MDG using BRFPlus

Working with Data Sources in the SAP Business One UI API

Quick View Insider: How Do I Set Quick View as SNC s Entry Screen?

Remote Monitoring User for IBM DB2 for LUW

SMP541. SAP Mobile Platform 3.0 Native and Hybrid Application Development COURSE OUTLINE. Course Version: 15 Course Duration: 5 Day(s)

LO Extraction - Part 6 Implementation Methodology

Building a Real-time Dashboard using Xcelsius and Data Integrator

Web Dynpro: Column Coloring in ALV

July, SAP Crystal Reports 2011 SP04 Product Availability Matrix (PAM)

How to Work with Analytical Portal

Overview of Caffeine ABAP to Go

SMP521. SAP Mobile Platform - Native and Hybrid Application Development COURSE OUTLINE. Course Version: 10 Course Duration: 5 Day(s)

The Dbmlsync API. A whitepaper from Sybase ianywhere Author: Joshua Savill, Product Manager Date: October 30 th, 2008

Personalizing SAP BusinessObjects Explorer Information Spaces

EDB377. Fast Track to SAP Replication Server Administration COURSE OUTLINE. Course Version: 15 Course Duration: 5 Day(s)

Extending DME Transfer Files According to Spanish Banking Control Council to Support Non- Euro Payments

Upgrade MS SQL 2005 to MS SQL 2008 (R2) for Non-High-Availability NW Mobile ABAP System

SAP ME Build Tool 6.1

EP200. SAP NetWeaver Portal: System Administration COURSE OUTLINE. Course Version: 10 Course Duration: 5 Day(s)

How to Integrate Google Maps into a Web Dynpro ABAP Application Using the Page Builder

How to Integrate Microsoft Bing Maps into SAP EHS Management

How to do a Manual Kernel Upgrade of an SAP Server

NET312. UI Development with Web Dynpro for ABAP COURSE OUTLINE. Course Version: 10 Course Duration: 4 Day(s)

Transcription:

INTRODUCTION TO JAVASCRIPT OBJECTS Fall 2009 CSCI 3110 Advanced Topics in Web Development Topics Object oriented programming in JavaScript Factory Pattern Constructor t Ptt Pattern Prototype Pattern Dynamic Prototype Pattern 1

Classless Objects JavaScript has no class definitions. Objects are created based on the language defined Object construct. To create multiple objects based on a desired object structure, functions written to guide instantiation. http://einstein.etsu.edu/~pittares/csci3110/examples/6 1.htm JavaScript's class free object oriented structure is a frequently criticized iii element. Factory Pattern One way to create multiple objects with the same properties and functions is to use the Factory Pattern design pattern. Function takes in property values, creates an object, assigns properties and functions to the object, and returns the object. The function becomes an "object factory". http://einstein.etsu.edu/~pittares/csci3110/examples/6 2.htm Use identifiers beginning with capital letters for objects (only) to denote distinction from identifiers used with primitive data types. 2

Constructor Pattern Another alternative is the Constructor Pattern. With this pattern, an object is created (using new) in the function call. http://einstein.etsu.edu/~pittares/csci3110/examples/6 3.htm The constructor function name is the name of the desired object. this is used in parameter/property and function assignment. instanceof instanceof is a JavaScript operator used to see if a particular object is an instance of (an instantiation of) a particular objectpattern. An object created with the Constructor Pattern is an instanceof both Object and the specified constructor name. An object created with the Factory Pattern is an instanceof Object only. http://einstein.etsu.edu/~pittares/csci3110/examples/6 3a.htm 3

Prototype Pattern Another alternative is the Prototype Pattern. With this pattern, memory and resources are used more efficiently as multiple objects share resources. The Constructor function body is (typically) null. and functions are assigned to the constructed object's prototype. prototype is a default property within an object that contains properties and methods available to all instances ofthat object. This technique allows defining 'default values' for objects and object functions. The object creation call does not specify property values. http://einstein.etsu.edu/~pittares/csci3110/examples/6 4.htm Prototype pattern With the Prototype Pattern, value assignments to the instantiated (or instance) object shadow property values in the prototype (they do not replace them). (Creating a 'search order'.) delete can be used to remove a property/value pair from an object. http://einstein.etsu.edu/~pittares/csci3110/examples/6 5.htm 4

Comparing the patterns Factory Pattern and Constructor Pattern Object Prototype Pattern Prototype Object Object Object Object Overridden Overridden Overridden Overridden tostring Each object contains a language defined function tostring which outputs the object as a String. Unless overridden in our object instance, this will output "[object Object]". http://einstein.etsu.edu/~pittares/csci3110/examples/6 5a.htm This function can/should be overridden based on our desire of how the object should be represented as a string. http://einstein.etsu.edu/~pittares/csci3110/examples/6 5b.htm 5

Test your skills In the prototype or the instance? The in operator checks to see whether a specified property is present within an object. http://einstein.etsu.edu/~pittares/csci3110/examples/6 6.htm / / / / object.hasownproperty("x") checks whether property x is present in the object instance. (i.e. it is not there because of the prototype) http://einstein.etsu.edu/~pittares/csci3110/examples/6 7.htm 6

Checking for, enumerating properties The for in loop can be used to enumerate all properties and functions present in an object. http://einstein.etsu.edu/~pittares/csci3110/examples/6 8.htm / / / / http://einstein.etsu.edu/~pittares/csci3110/examples/6 9.htm http://einstein.etsu.edu/~pittares/csci3110/examples/6 10.htm Ordering of properties within anobject is not fixed. Test your understanding 7

Property enumeration When properties of an object are enumerated, some properties are not listed. Somebuilt in properties aredesignated as nonenumerable. Examples include tostring and others. Browsers are inconsistent in their behavior of these non enumerable elements. In IE, if you override the non enumerable property with your own, your override is still non enumerable. In Opera, Safari, and Firefox the behavior varies depending on property. http://einstein.etsu.edu/~pittares/csci3110/examples/6 11.htm Dynamic Prototype Pattern 2 notable disadvantages of using the "pure" Prototype Pattern: 1. Cannot instantiate and set properties in one line. 2. As all instances are references to the prototype, if the prototype contains an object, this single object is shared among all instances. Solution: use a combination of the Constructor and Prototype Patterns the Dynamic Prototype Pattern. set in the Constructor pattern fashion. Each function set on the prototype if notalreadyin existence. http://einstein.etsu.edu/~pittares/csci3110/examples/6 12.htm http://einstein.etsu.edu/~pittares/csci3110/examples/6 13.htm 8

Object Patterns Benefit of object patterns can learn syntax/pattern and reuse with confidence. Other object patterns exist itof varying complexity. Topics Object oriented programming in JavaScript Factory Pattern Constructor t Ptt Pattern Prototype Pattern Constructor/Prototype Pattern 9

Copyrights Presentation prepared by and copyright of Dr. Tony Pittarese, East Tennessee State University, Computer and Information Sciences Dept. (pittares@etsu.edu) Podcast lecture related to this presentation available via ETSU itunesu (http://www.etsu.edu/itunesu/ ). Microsoft, Windows, Excel, Outlook, and PowerPoint are registered trademarks of Microsoft Corporation. IBM, DB2, DB2 Universal Database, System i, System i5, System p, System p5, System x, System z, System z10, System z9, z10, z9, iseries, pseries, xseries, zseries, eserver, z/vm, z/os, i5/os, S/390, OS/390, OS/400, AS/400, S/390 Parallel Enterprise Server, PowerVM, Power Architecture, POWER6+, POWER6, POWER5+, POWER5, POWER, OpenPower, PowerPC, BatchPipes, BladeCenter, System Storage, GPFS, HACMP, RETAIN, DB2 Connect, RACF, Redbooks, OS/2, Parallel Sysplex, MVS/ESA, AIX, Intelligent Miner, WebSphere, Netfinity, Tivoli and Informix are trademarks or registered trademarks of IBM Corporation. Linux is the registered trademark of Linus Torvalds in the U.S. and other countries. Oracle is a registered trademark of Oracle Corporation. HTML, XML, XHTML and W3C are trademarks or registered trademarks of W3C, World Wide Web Consortium, Massachusetts Institute of Technology. Java is a registered trademark of Sun Microsystems, Inc. JavaScript is a registered trademark of Sun Microsystems, Inc., used under license for technology invented and implemented by Netscape. SAP, R/3, SAP NetWeaver, Duet, PartnerEdge, ByDesign, SAP Business ByDesign, and other SAP products and services mentioned herein as well as their respective logos are trademarks or registered trademarks of SAP AG in Germany and other countries. Business Objects and the Business Objects logo, BusinessObjects, Crystal Reports, Crystal Decisions, Web Intelligence, Xcelsius, and other Business Objects products and services mentioned herein as well as their respective logos are trademarks or registered trademarks of Business Objects S.A. in the United States and in other countries. Business Objects is an SAP company. ERPsim is a registered copyright of ERPsim Labs, HEC Montreal. Other products mentioned in this presentation are trademarks of their respective owners. 10