TERSUBSCRIBE. E s s e n t i a l f o r s o f t w a r e t e s t e r s. It s FREE for testers. June / 5 v2.0 number 27

Size: px
Start display at page:

Download "TERSUBSCRIBE. E s s e n t i a l f o r s o f t w a r e t e s t e r s. It s FREE for testers. June / 5 v2.0 number 27"

Transcription

1 TE It s FREE for testers TERSUBSCRIBE E s s e n t i a l f o r s o f t w a r e t e s t e r s June / 5 v2.0 number 27 Including articles by: Bogdan Bereza VictO Jim Pelech and Gregory Solovey Alcatel-Lucent Sakis Ladopoulos Intrasoft International Buu Nguyen QASymphony

2 Promises, promises by Buu Nguyen In JavaScript, callbacks are now test incidents of the program that called the subprogram must continue while the subprogram is waiting. Otherwise, to take a crude example, nothing else on a page will work when a movie is loading or playing. In this article I will explain why code that achieves this by the most common method, callback functions, is prone to defect and failure, as a guide to testers using code review, static/dynamic analysis and code-based test design techniques. Then I will explain a new, I think better, approach to doing the same thing, which developers, testers and test automators of web applications need, I believe, to understand and adopt now. Callbacks and cyclomatic complexity Figure 1 shows a program that downloads and displays (figure 2 my Github repositories. Buu Nguyen s topical tutorial on web apps code quality JavaScript programs are especially prone to failure. Although they are an integral part of any non-trivial web application, and the language is loved by many, the experience of most people who have written, tested or debugged them, whether for production or for test automation purposes, bears this out. The reason is probably that JavaScript is single-threaded yet is frequently needed to behave asynchronously. When invoking a method or function, it often cannot be allowed to wait for the invoked code to complete execution and return its result, because the invoked code may need to wait a long time for something else to happen, for example data to download or a web service to respond. The execution The first call to getjson( downloads, asynchronously, the list of repositories then invokes the passed-in callback. Subsequent calls to getjson(, nested in the first callback, download the details of individual repository and invoke their own callbacks. The program has two levels of nested callbacks. Now imagine two additional requirements: as well as the html_url, for each repository, the contributors url is to be displayed. And while the document is being downloaded an animated GIF is displayed. These make the code shape look like figure 3. So: the depth of nesting increases with the number of requirements. JavaScript programmers call this code shape the pyramid of doom. Now imagine what happens when further additional requirements create a need for 20 PT - June professionaltester.com

3 function showerror(err { var errelm = document.getelementbyid( error errelm.innertext = err function addrepo(repo { if (repo.source return // ignore forked repo var reposelm = document.getelementbyid( repos reposelm.innerhtml += <li><a href= + (repo.homepage repo.html_url + >; + repo.name + </a>: + repo.description + </li> function getjson(url, cb { var xhr = new XMLHttpRequest( xhr.open( GET, url, true xhr.onreadystatechange = function( { if (xhr.readystate!== 4 return if (xhr.status === 200 cb(null, JSON.parse(xhr.responseText else cb(xhr.statustext xhr.send( // callback hell starts here getjson( function(err, repos { if (err return showerror(err repos.foreach(function(repo { getjson(repo.url, function(err, repodetails { if (err return showerror(err addrepo(repodetails Figure 1: program with callbacks bike: Interpreted language built on.net/mono grunt-mindirect: Grunt task to perform in-place JS minification combres: ASP.NET and MVC performance optimization library jcr: jquery Carousel evtify: Event emitter for Node & browser jundo: JavaScript Undo Library local-server: Minimal static server memento: Lightweight and extensible undo framework for.net LeapPhoto: Sample app: control iphoto with Leap Motion misc-js: Miscellaneous JavaScript notify: Change tracking library for.net qdds: Quick & dirty map and set data structures promise: Minimal promise implementation qtrace-samples: Sample code for qtrace publishers semicolon: Semicolon interpreter in Python starx: Generator executor for ECMAScript 6 Figure 2: output of program PT - June professionaltester.com 21

4 showanim(..., function( { // animation getjson(..., function( { // repos getjson(..., function( { // repo getjson(function( { // contributor Figure 3: callback nesting depth var p1 = getjson(someurl var p2 = p1.then( function onfulfilled1(value { return value.number * 2, function onrejected1(reason { // recover or throw p2.then( function onfulfilled2(value { console.log(value, function onrejected2(reason { // recover or throw Figure 4: promise chaining var p1 = getjson(someurl var p2 = p1.then( function onfulfilled1(value { return value.number * 2 p2.then( function onfulfilled2(value { console.log(value, function onrejected2(reason { // handle error Figure 5: handler is undefined or not a function decisions in the invoking code: for example if the repository is a fork, the content of forks_url is to be displayed. This requires, or does not, a further callback, depending on the result and status of a callback. Cyclomatic complexity has just gone through the roof. JavaScript programmers call this phenomenon callback hell, with good reason. It is extremely difficult to fix or maintain. Callbacks and error handling What if one of the invoked functions reports an error (including a timeout it is necessary to define a mechanism to propagate errors occurred in asynchronous operations and handle them in callbacks. In figure 1, getjson( passes any error as the first argument of its callback, which has to look at the value of that error to decide what to do next. If multiple callbacks are active, they must all propagate errors the same way, or CC will be multiplied again. Handling errors in asynchronous operations is one thing: if any error is thrown inside a callback itself, that error is left unhandled. Adding a big try-catch around the first call to getjson( won t work because each callback is executed in its separate call stack. Instead, a trycatch must be added to every callback! Doing this is a daunting and onerous task even for this small program and usually left undone. In production web applications, failures caused by this issue are often simply tolerated; it is hoped that the user will try again. Callbacks and performance and functionality The code to display repository information has to be executed multiple times, each time with a different repository object as soon as it is downloaded. This is inefficient; real applications would probably benefit from updating the DOM in batch. A corollary of this problem is that the order in which repositories are added to the DOM is not the same as the order of the repos array. Therefore the repos array cannot be sorted, for example by number of stars or forks, before invoking foreach( on it, or the result will be random. Hanging up on callbacks Naming the anonymous functions, encapsulating (modularizing exception handlers or utilizing modules such as async can 22 PT - June professionaltester.com

5 help developers to write asynchronous JavaScript faster and more simply. But they do nothing to help testers by reducing cyclomatic complexity or improving testability. In fact they make both worse by, approximately, an order of magnitude. An alternative approach to callbacks, promises, has been proven in use with third-party libraries that implement it. But it will soon be in the JavaScript standard (that is, ECMAScript 6 and therefore part of native JavaScript. This will make the use of callbacks redundant and wrong. Testers detecting their use, now, should raise an incident. The promises of the (near future A promise represents an eventual result of an invocation (usually asynchronous, but it doesn t have to be. A promise is always in one of three states: pending, fulfilled and rejected. Pending means the operation has not completed (including, has not started. When the operation completes successfully, the promise is fulfilled with the value, that is the output. Otherwise, if there s an error in the process, the promise is rejected with a reason. Once a promise is fulfilled or rejected, it cannot be transitioned to another state and its value (or reason cannot be changed. Imagine this call to a promise-aware version of the getjson( function: var p1 = getjson( someurl The variable p1 is a promise. It is not the JSON object itself, because the code to download the JSON is executed asynchronously and not completed by the time p1 is assigned. Instead, p1 represents the JSON object that will, perhaps, be available at some point. Now, p1 is a first-class JavaScript object, so we can pass it around to other functions or return it from the current function. Anything interested in the value of p1 can invoke a special method on p1, for example p1.then(, and pass it in an onfulfilled or onrejected handler, for example: p1.then(onfulfilled, onrejected If getjson( successfully downloads the JSON, onfulfilled will be invoked. If there is any error, onrejected will be invoked. If multiple handlers are needed, p1.then( can be called multiple times. Promise chaining The then( method returns a new promise, making it possible to chain operations. In the example in figure 4, assume the JSON retrieved by getjson( is an object with a property called number. Now p1. then( returns a promise, p2. We register handlers to both promises, p1 and p2. With this wiring, the following behaviours are made possible: once the code in getjson( finishes downloading the JSON, onfulfilled1 is invoked with the JSON object. If there is any error in getjson(, onrejected1 is invoked as soon as onfulfilled1 (or onrejected1 is invoked and if there s no error thrown, p2 will be fulfilled with the returned value of onfulfilled1 (or of onrejected1, causing onfulfilled2 to be invoked with that value. On the other hand, if there is any error thrown in onfulfilled1 (or in onrejected1, p2 is rejected and onrejected2 will be invoked with the error. Effectively, the value returned or error thrown by every onfulfilled or onrejected is bubbled to the next handler in the then( chain. If you want to handle any potential error thrown by onfulfilled2 and onrejected2, simply chain another then top2. then(, like this: p2.then(onfulfilled2, onrejected2.then(null, onrejected3. This brings us to a special case: if a handler is undefined or not a function, as the fulfillment handler of the final then( above, the next handler of the same type in the chain, if any, will be invoked with the PT - June professionaltester.com 23

6 ;(function( { function Promise( { var state = pending, callbacks = [], value function then(onfulfilled, onrejected { var p = new Promise( function callback( { var cb = state === resolved? onfulfilled : onrejected if (typeof cb === function { try { var ret = cb(value if (ret === p return p.reject(new TypeError( Cannot resolve itself if (ret instanceof Promise return ret.then(p.resolve, p.reject p.resolve(ret catch (e { p.reject(e else p[state === resolved? resolve : reject ](value if (state === pending callbacks.push(callback else nexttick(callback return p function complete(_state { return function(_value { if (state!== pending return state = _state value = _value nexttick(function( { for (var cb; cb = callbacks.shift(; cb( this.then = then this.resolve = complete( resolved this.reject = complete( rejected Promise.all = function(promises { var cp = new Promise(, values = [], remain = promises.length for (var i = 0; promises[i]; i++ { ;(function(i { promises[i].then(function(value { values[i] = value if (--remain === 0 cp.resolve(values, cp.reject (i return cp if (typeof module!== undefined && module.exports { module.exports = Promise var nexttick = process.nexttick else { window.promise = Promise var nexttick = window.setimmediate window.settimeout ( Figure 6: promise library 24 PT - June professionaltester.com

7 function addrepos(repos { var reposelm = document.getelementbyid( repos var parts = repos.map(function(repo { return repo.source? : <li> <a href= + (repo.homepage repo.html_url + > + repo.name + </a>: + repo.description + </li> reposelm.innerhtml = parts.join( function showerror(err { var errelm = document.getelementbyid( error errelm.innertext = err function getjson(url { var p = new Promise( try { var xhr = new XMLHttpRequest( xhr.open( GET, url, true xhr.onreadystatechange = function( { if (xhr.readystate!== 4 return if (xhr.status === 200 p.resolve(json.parse(xhr.responsetext else p.reject(xhr.statustext xhr.send( catch (e { p.reject(e return p getjson( repos.then( function(repos { return Promise.all(repos.map(function(repo { return getjson(repo.url.then(addrepos.then(null, showerror Figure 7: program rewritten using the library current value or error. For example, if onrejected2 is missing, onrejected3 will be invoked with the error that was meant for the missing onrejected2. In other words, if we don t need special error handling for getjson(, we can rewrite our program as in figure 5. Another special case is when a handler returns a promise instead of a normal value. For example, if onfulfilled1 returns a new promise as in figure 6, p2 will share the state with p3, so p2 will be fulfilled or rejected when p3 is fulfilled or rejected respectively. Promise aggregation Multiple promises can be aggregated to form a composite promise. For example: var cp = Promise.all(p1, p2, p3 cp.then(function(results { If p1, p2 and p3 are promises, cp represents the aggregation of the eventual values they will eventually represent. When cp is fulfilled, its onfulfill handlers will be invoked with an array of values of p1, p2 and p3 in the right order. On the other hand, if one of the child promises is rejected, cp will be rejected. A promise library Figure 6 shows the full code of a promise library that addresses all the problems described above and allows the program shown in figure 1 to be rewritten as in figure 7. Now there is no need for nesting level/cyclomatic complexity to increase; error handling is straightforward; results are aggregated in order; and the DOM is updated all at once. The program is now also highly extensible: to perform additional transformations to the data, asynchronously or not, simply chain more then(s to the returned promise Buu Nguyen is director of technology at QASymphony ( a leading provider of test management platforms for agile development teams PT - June professionaltester.com 25

Asynchronous Programming in Javascript, Part 2. CSCI 5828: Foundations of Software Engineering Lecture 19 10/25/2016

Asynchronous Programming in Javascript, Part 2. CSCI 5828: Foundations of Software Engineering Lecture 19 10/25/2016 Asynchronous Programming in Javascript, Part 2 CSCI 5828: Foundations of Software Engineering Lecture 19 10/25/2016 1 Goals Discussed asynchronous programming in Javascript in Lecture 18 The gap between

More information

Package promises. April 13, 2018

Package promises. April 13, 2018 Type Package Package promises April 13, 2018 Title Abstractions for Promise-Based Asynchronous Programming Version 1.0.1 Provides fundamental abstractions for doing asynchronous programming in R using

More information

Copyright Descriptor Systems, Course materials may not be reproduced in whole or in part without prior written consent of Joel Barnum

Copyright Descriptor Systems, Course materials may not be reproduced in whole or in part without prior written consent of Joel Barnum Ajax The notion of asynchronous request processing using the XMLHttpRequest object has been around for several years, but the term "AJAX" was coined by Jesse James Garrett of Adaptive Path. You can read

More information

Networking & The Web. HCID 520 User Interface Software & Technology

Networking & The Web. HCID 520 User Interface Software & Technology Networking & The HCID 520 User Interface Software & Technology Uniform Resource Locator (URL) http://info.cern.ch:80/ 1991 HTTP v0.9 Uniform Resource Locator (URL) http://info.cern.ch:80/ Scheme/Protocol

More information

Networking & The Web. HCID 520 User Interface Software & Technology

Networking & The Web. HCID 520 User Interface Software & Technology Networking & The Web HCID 520 User Interface Software & Technology Uniform Resource Locator (URL) http://info.cern.ch:80/ 1991 HTTP v0.9 Uniform Resource Locator (URL) http://info.cern.ch:80/ Scheme/Protocol

More information

The Eval that Men Do

The Eval that Men Do The Eval that Men Do Gregor Richard Christian Hammer Brian Burg Jan Vitek Vincent Foley-Bourgon COMP-621 - Winter 2014 McGill University February 2014 The paper Information 3 authors from Purdue University

More information

Don't Call Us, We'll Call You:

Don't Call Us, We'll Call You: Don't Call Us, We'll Call You: Characterizing Callbacks in JavaScript Keheliya Gallaba, Ali Mesbah, Ivan Beschastnikh University of British Columbia 1 Why JavaScript? On the client 2 Why JavaScript? On

More information

Controller/server communication

Controller/server communication Controller/server communication Mendel Rosenblum Controller's role in Model, View, Controller Controller's job to fetch model for the view May have other server communication needs as well (e.g. authentication

More information

5. Strict mode use strict ; 6. Statement without semicolon, with semicolon 7. Keywords 8. Variables var keyword and global scope variable 9.

5. Strict mode use strict ; 6. Statement without semicolon, with semicolon 7. Keywords 8. Variables var keyword and global scope variable 9. Javascript 1) Javascript Implementation 1. The Core(ECMAScript) 2. DOM 3. BOM 2) ECMAScript describes 1. Syntax 2. Types 3. Statements 4. Keywords 5. Reserved words 6. Operators 7. Objects 3) DOM 1. Tree

More information

Controller/server communication

Controller/server communication Controller/server communication Mendel Rosenblum Controller's role in Model, View, Controller Controller's job to fetch model for the view May have other server communication needs as well (e.g. authentication

More information

Web Application Development

Web Application Development Web Application Development Produced by David Drohan (ddrohan@wit.ie) Department of Computing & Mathematics Waterford Institute of Technology http://www.wit.ie SERVER SIDE JAVASCRIPT PART 1 Outline 1.

More information

IN Development in Platform Ecosystems Lecture 3: json, ajax, APIs

IN Development in Platform Ecosystems Lecture 3: json, ajax, APIs IN5320 - Development in Platform Ecosystems Lecture 3: json, ajax, APIs 3rd of September 2018 Department of Informatics, University of Oslo Magnus Li - magl@ifi.uio.no 1 Today s lecture 1. Objects and

More information

Callbacks & Promises

Callbacks & Promises Callbacks & Promises Agenda Task: read a JSON file A Callback Based Library (fs) A Promise based Libdary (fs-readfile-promise) Function Styles: Anonymous function Named function Function Object Named Arrow

More information

Debugging AJAX in Production

Debugging AJAX in Production Debugging AJA in Production Lacking proper browser support, what steps can we take to debug production AJA code? Eric Schrock, Sun Microsystems The JavaScript language has a curious history. What began

More information

AJAX ASYNCHRONOUS JAVASCRIPT AND XML. Laura Farinetti - DAUIN

AJAX ASYNCHRONOUS JAVASCRIPT AND XML. Laura Farinetti - DAUIN AJAX ASYNCHRONOUS JAVASCRIPT AND XML Laura Farinetti - DAUIN Rich-client asynchronous transactions In 2005, Jesse James Garrett wrote an online article titled Ajax: A New Approach to Web Applications (www.adaptivepath.com/ideas/essays/archives/000

More information

The Promised Land: Untangling Async Spaghetti Code

The Promised Land: Untangling Async Spaghetti Code The Promised Land: Untangling Async Spaghetti Code Presented by Trevor Burnham at FluentConf 2012 Preface The Compleat History of JavaScript (in about a minute) 1995: JavaScript discovered 2001: pg says

More information

Module 5 JavaScript, AJAX, and jquery. Module 5. Module 5 Contains an Individual and Group component

Module 5 JavaScript, AJAX, and jquery. Module 5. Module 5 Contains an Individual and Group component Module 5 JavaScript, AJAX, and jquery Module 5 Contains an Individual and Group component Both are due on Wednesday October 24 th Start early on this module One of the most time consuming modules in the

More information

JavaScript CS 4640 Programming Languages for Web Applications

JavaScript CS 4640 Programming Languages for Web Applications JavaScript CS 4640 Programming Languages for Web Applications 1 How HTML, CSS, and JS Fit Together {css} javascript() Content layer The HTML gives the page structure and adds semantics Presentation

More information

ES Promise.

ES Promise. ES Promise Walkthrough @san650 A Promise represents a value which may be available now, or in the future, or never. Promise A Promise is a proxy for a value not necessarily known when the promise is created.

More information

Asynchronous Functions in C#

Asynchronous Functions in C# Asynchronous Functions in C# Asynchronous operations are methods and other function members that may have most of their execution take place after they return. In.NET the recommended pattern for asynchronous

More information

JavaScript CS 4640 Programming Languages for Web Applications

JavaScript CS 4640 Programming Languages for Web Applications JavaScript CS 4640 Programming Languages for Web Applications 1 How HTML, CSS, and JS Fit Together {css} javascript() Content layer The HTML gives the page structure and adds semantics Presentation

More information

! The final is at 10:30 am, Sat 6/4, in this room. ! Open book, open notes. ! No electronic devices. ! No food. ! Assignment 7 due 10pm tomorrow

! The final is at 10:30 am, Sat 6/4, in this room. ! Open book, open notes. ! No electronic devices. ! No food. ! Assignment 7 due 10pm tomorrow Announcements ECS 89 6/1! The final is at 10:30 am, Sat 6/4, in this room! Open book, open notes! No electronic devices! No food! Assignment 7 due 10pm tomorrow! No late Assignment 7 s! Fill out course

More information

Testing is a very big and important topic when it comes to software development. Testing has a number of aspects that need to be considered.

Testing is a very big and important topic when it comes to software development. Testing has a number of aspects that need to be considered. Testing Testing is a very big and important topic when it comes to software development. Testing has a number of aspects that need to be considered. System stability is the system going to crash or not?

More information

CS312: Programming Languages. Lecture 21: JavaScript

CS312: Programming Languages. Lecture 21: JavaScript CS312: Programming Languages Lecture 21: JavaScript Thomas Dillig Thomas Dillig, CS312: Programming Languages Lecture 21: JavaScript 1/25 Why Discuss JavaScript? JavaScript is very widely used and growing

More information

An Async Primer. By Bill Wagner August Introduction

An Async Primer. By Bill Wagner August Introduction An Async Primer By Bill Wagner August 2012 Introduction The C# 5.0 release might seem small, given that the single major feature is the addition of async / await keywords to support asynchronous programming.

More information

Exception Handling Introduction. Error-Prevention Tip 13.1 OBJECTIVES

Exception Handling Introduction. Error-Prevention Tip 13.1 OBJECTIVES 1 2 13 Exception Handling It is common sense to take a method and try it. If it fails, admit it frankly and try another. But above all, try something. Franklin Delano Roosevelt O throw away the worser

More information

Welcome to CS50 section! This is Week 10 :(

Welcome to CS50 section! This is Week 10 :( Welcome to CS50 section! This is Week 10 :( This is our last section! Final project dates Official proposals: due this Friday at noon Status report: due Monday, Nov 28 at noon Hackathon: Thursday, Dec

More information

The course is supplemented by numerous hands-on labs that help attendees reinforce their theoretical knowledge of the learned material.

The course is supplemented by numerous hands-on labs that help attendees reinforce their theoretical knowledge of the learned material. Lincoln Land Community College Capital City Training Center 130 West Mason Springfield, IL 62702 217-782-7436 www.llcc.edu/cctc WA2442 Introduction to JavaScript Objectives This intensive training course

More information

Why Discuss JavaScript? CS312: Programming Languages. Lecture 21: JavaScript. JavaScript Target. What s a Scripting Language?

Why Discuss JavaScript? CS312: Programming Languages. Lecture 21: JavaScript. JavaScript Target. What s a Scripting Language? Why Discuss JavaScript? CS312: Programming Languages Lecture 21: JavaScript Thomas Dillig JavaScript is very widely used and growing Any AJAX application heavily relies on JavaScript JavaScript also has

More information

Exceptions in Java

Exceptions in Java Exceptions in Java 3-10-2005 Opening Discussion Do you have any questions about the quiz? What did we talk about last class? Do you have any code to show? Do you have any questions about the assignment?

More information

JS Event Loop, Promises, Async Await etc. Slava Kim

JS Event Loop, Promises, Async Await etc. Slava Kim JS Event Loop, Promises, Async Await etc Slava Kim Synchronous Happens consecutively, one after another Asynchronous Happens later at some point in time Parallelism vs Concurrency What are those????

More information

CISC 1600 Lecture 2.4 Introduction to JavaScript

CISC 1600 Lecture 2.4 Introduction to JavaScript CISC 1600 Lecture 2.4 Introduction to JavaScript Topics: Javascript overview The DOM Variables and objects Selection and Repetition Functions A simple animation What is JavaScript? JavaScript is not Java

More information

Index. Ray Nicholus 2016 R. Nicholus, Beyond jquery, DOI /

Index. Ray Nicholus 2016 R. Nicholus, Beyond jquery, DOI / Index A addclass() method, 2 addeventlistener, 154, 156 AJAX communication, 20 asynchronous operations, 110 expected and unexpected responses, 111 HTTP, 110 web sockets, 111 AJAX requests DELETE requests,

More information

What is Node.js? Tim Davis Director, The Turtle Partnership Ltd

What is Node.js? Tim Davis Director, The Turtle Partnership Ltd What is Node.js? Tim Davis Director, The Turtle Partnership Ltd About me Co-founder of The Turtle Partnership Working with Notes and Domino for over 20 years Working with JavaScript technologies and frameworks

More information

Part I: Introduction to Functions

Part I: Introduction to Functions Computer Science & Engineering 120 Learning to Code Organizing Code I Functions Part I: Introduction to Functions Christopher M. Bourke cbourke@cse.unl.edu Topic Overview Functions Why Functions? Defining

More information

TERSUBSCRIBE. E s s e n t i a l f o r s o f t w a r e t e s t e r s. It s FREE for testers. August / 5 v2.0 number 22. Including articles by:

TERSUBSCRIBE. E s s e n t i a l f o r s o f t w a r e t e s t e r s. It s FREE for testers. August / 5 v2.0 number 22. Including articles by: TE It s FREE for testers TERSUBSCRIBE E s s e n t i a l f o r s o f t w a r e t e s t e r s August 2013 4 / 5 v2.0 number 22 Including articles by: Bogdan Bereza VictO Mark Lehky Sven Euteneuer SQS Migration

More information

Software Design and Analysis for Engineers

Software Design and Analysis for Engineers Software Design and Analysis for Engineers by Dr. Lesley Shannon Email: lshannon@ensc.sfu.ca Course Website: http://www.ensc.sfu.ca/~lshannon/courses/ensc251 Simon Fraser University Slide Set: 9 Date:

More information

Asynchronous Interactions and Managing Modeless UI with Autodesk Revit API

Asynchronous Interactions and Managing Modeless UI with Autodesk Revit API Asynchronous Interactions and Managing Modeless UI with Autodesk Revit API Arnošt Löbel Sr. Principal Software Engineer, Autodesk, Inc. Class Summary In this class we will explore the realms of challenging

More information

Human-Computer Interaction Design

Human-Computer Interaction Design Human-Computer Interaction Design COGS120/CSE170 - Intro. HCI Instructor: Philip Guo Lab 6 - Connecting frontend and backend without page reloads (2016-11-03) by Michael Bernstein, Scott Klemmer, and Philip

More information

JavaScript. The Bad Parts. Patrick Behr

JavaScript. The Bad Parts. Patrick Behr JavaScript The Bad Parts Patrick Behr History Created in 1995 by Netscape Originally called Mocha, then LiveScript, then JavaScript It s not related to Java ECMAScript is the official name Many implementations

More information

Comprehensive AngularJS Programming (5 Days)

Comprehensive AngularJS Programming (5 Days) www.peaklearningllc.com S103 Comprehensive AngularJS Programming (5 Days) The AngularJS framework augments applications with the "model-view-controller" pattern which makes applications easier to develop

More information

Test-Driven Development (TDD)

Test-Driven Development (TDD) Test-Driven Development (TDD) CS 4501 / 6501 Software Testing [Lasse Koskela, Test Driven, Chapters 2-3] 1 Agile Airplane Testing Test harness: Appearance matches Color coding in place Fly 6ft (or 2m)

More information

Simple AngularJS thanks to Best Practices

Simple AngularJS thanks to Best Practices Simple AngularJS thanks to Best Practices Learn AngularJS the easy way Level 100-300 What s this session about? 1. AngularJS can be easy when you understand basic concepts and best practices 2. But it

More information

JavaScript: the language of browser interactions. Claudia Hauff TI1506: Web and Database Technology

JavaScript: the language of browser interactions. Claudia Hauff TI1506: Web and Database Technology JavaScript: the language of browser interactions Claudia Hauff TI1506: Web and Database Technology ti1506-ewi@tudelft.nl Densest Web lecture of this course. Coding takes time. Be friendly with Codecademy

More information

Part of this connection identifies how the response can / should be provided to the client code via the use of a callback routine.

Part of this connection identifies how the response can / should be provided to the client code via the use of a callback routine. What is AJAX? In one sense, AJAX is simply an acronym for Asynchronous JavaScript And XML In another, it is a protocol for sending requests from a client (web page) to a server, and how the information

More information

Unifer Documentation. Release V1.0. Matthew S

Unifer Documentation. Release V1.0. Matthew S Unifer Documentation Release V1.0 Matthew S July 28, 2014 Contents 1 Unifer Tutorial - Notes Web App 3 1.1 Setting up................................................. 3 1.2 Getting the Template...........................................

More information

JavaScript: the Big Picture

JavaScript: the Big Picture JavaScript had to look like Java only less so be Java's dumb kid brother or boy-hostage sidekick. Plus, I had to be done in ten days or something worse than JavaScript would have happened.! JavaScript:

More information

Intro To Javascript. Intro to Web Development

Intro To Javascript. Intro to Web Development Intro To Javascript Intro to Web Development Preamble I don't like JavaScript But with JS your feelings don't matter. Browsers don't work well with any other language so you have to write code that either:

More information

CGS 3066: Spring 2015 JavaScript Reference

CGS 3066: Spring 2015 JavaScript Reference CGS 3066: Spring 2015 JavaScript Reference Can also be used as a study guide. Only covers topics discussed in class. 1 Introduction JavaScript is a scripting language produced by Netscape for use within

More information

Contents. Demos folder: Demos\14-Ajax. 1. Overview of Ajax. 2. Using Ajax directly. 3. jquery and Ajax. 4. Consuming RESTful services

Contents. Demos folder: Demos\14-Ajax. 1. Overview of Ajax. 2. Using Ajax directly. 3. jquery and Ajax. 4. Consuming RESTful services Ajax Contents 1. Overview of Ajax 2. Using Ajax directly 3. jquery and Ajax 4. Consuming RESTful services Demos folder: Demos\14-Ajax 2 1. Overview of Ajax What is Ajax? Traditional Web applications Ajax

More information

Chris Buckett. FOREWORD BY Seth Ladd MANNING 6$03/(&+$37(5

Chris Buckett. FOREWORD BY Seth Ladd MANNING 6$03/(&+$37(5 Chris Buckett FOREWORD BY Seth Ladd 6$03/(&+$37(5 MANNING Dart in Action by Chris Buckett Chapter 9 Copyright 2013 Manning Publications brief contents PART 1 INTRODUCING DART...1 1 Hello Dart 3 2 Hello

More information

AJAX: Asynchronous Event Handling Sunnie Chung

AJAX: Asynchronous Event Handling Sunnie Chung AJAX: Asynchronous Event Handling Sunnie Chung http://adaptivepath.org/ideas/ajax-new-approach-web-applications/ http://stackoverflow.com/questions/598436/does-an-asynchronous-call-always-create-call-a-new-thread

More information

KTH Royal Institute of Technology SEMINAR 2-29 March Simone Stefani -

KTH Royal Institute of Technology SEMINAR 2-29 March Simone Stefani - KTH Royal Institute of Technology SEMINAR 2-29 March 2017 Simone Stefani - sstefani@kth.se WHAT IS THIS SEMINAR ABOUT Branching Merging and rebasing Git team workflows Pull requests and forks WHAT IS THIS

More information

Introduction to Coroutines. Roman Elizarov elizarov at JetBrains

Introduction to Coroutines. Roman Elizarov elizarov at JetBrains Introduction to Coroutines Roman Elizarov elizarov at JetBrains Asynchronous programming How do we write code that waits for something most of the time? A toy problem Kotlin 1 fun requesttoken(): Token

More information

DECOUPLING PATTERNS, SERVICES AND CREATING AN ENTERPRISE LEVEL EDITORIAL EXPERIENCE

DECOUPLING PATTERNS, SERVICES AND CREATING AN ENTERPRISE LEVEL EDITORIAL EXPERIENCE DECOUPLING PATTERNS, SERVICES AND CREATING AN ENTERPRISE LEVEL EDITORIAL EXPERIENCE Who we are and Why we are here? Saurabh Chugh Started Drupal journey in 2010 with Drupal 6, long journey with Drupal

More information

Client-Side Web Technologies. JavaScript Part I

Client-Side Web Technologies. JavaScript Part I Client-Side Web Technologies JavaScript Part I JavaScript First appeared in 1996 in Netscape Navigator Main purpose was to handle input validation that was currently being done server-side Now a powerful

More information

1 CS480W Quiz 6 Solution

1 CS480W Quiz 6 Solution 1 CS480W Quiz 6 Solution Date: Fri Dec 07 2018 Max Points: 15 Important Reminder As per the course Academic Honesty Statement, cheating of any kind will minimally result in receiving an F letter grade

More information

Using GitHub to Share with SparkFun a

Using GitHub to Share with SparkFun a Using GitHub to Share with SparkFun a learn.sparkfun.com tutorial Available online at: http://sfe.io/t52 Contents Introduction Gitting Started Forking a Repository Committing, Pushing and Pulling Syncing

More information

Index. Bare-bones connect application, 125 Binary JSON (BSON), 171. Callback functions asynchronous code ifelse, 199 loops,

Index. Bare-bones connect application, 125 Binary JSON (BSON), 171. Callback functions asynchronous code ifelse, 199 loops, Index A Amazon Web Services (AWS) console, 260 261 EBS, 262 EC2 Amazon Linux AMI, 262, 265 connect script and sample usage, 271 dashboard and Launch Instance, 265 global package installation, 273 hard

More information

INF5750. Introduction to JavaScript and Node.js

INF5750. Introduction to JavaScript and Node.js INF5750 Introduction to JavaScript and Node.js Outline Introduction to JavaScript Language basics Introduction to Node.js Tips and tools for working with JS and Node.js What is JavaScript? Built as scripting

More information

AJAX: The Basics CISC 282 March 25, 2014

AJAX: The Basics CISC 282 March 25, 2014 AJAX: The Basics CISC 282 March 25, 2014 Synchronous Communication User and server take turns waiting User requests pages while browsing Waits for server to respond Waits for the page to load in the browser

More information

LEARN HOW TO USE CA PPM REST API in 2 Minutes!

LEARN HOW TO USE CA PPM REST API in 2 Minutes! LEARN HOW TO USE CA PPM REST API in 2 Minutes! WANT TO LEARN MORE ABOUT CA PPM REST API? If you are excited about the updates to the REST API in CA PPM V14.4 and would like to explore some of the REST

More information

Full Stack Web Developer Nanodegree Syllabus

Full Stack Web Developer Nanodegree Syllabus Full Stack Web Developer Nanodegree Syllabus Build Complex Web Applications Before You Start Thank you for your interest in the Full Stack Web Developer Nanodegree! In order to succeed in this program,

More information

Lecture 5 8/24/18. Writing larger programs. Comments. What are we going to cover today? Using Comments. Comments in Python. Writing larger programs

Lecture 5 8/24/18. Writing larger programs. Comments. What are we going to cover today? Using Comments. Comments in Python. Writing larger programs What are we going to cover today? Lecture 5 Writing and Testing Programs Writing larger programs Commenting Design Testing Writing larger programs As programs become larger and more complex, it becomes

More information

Arjen de Blok. Senior Technical Consultant bij ICT Groep ( sinds 1995 Programmeren sinds 1990 Technologiën. Links

Arjen de Blok. Senior Technical Consultant bij ICT Groep (  sinds 1995 Programmeren sinds 1990 Technologiën. Links Arjen de Blok Senior Technical Consultant bij ICT Groep (www.ict.eu) sinds 1995 Programmeren sinds 1990 Technologiën Links Visual C++ met Microsoft Foundation Classes.NET WinForms & WPF Silverlight ASP.NET

More information

Lesson: Web Programming(6) Omid Jafarinezhad Sharif University of Technology

Lesson: Web Programming(6) Omid Jafarinezhad Sharif University of Technology Lesson: Web Programming(6) Omid Jafarinezhad Sharif University of Technology React QUICK START QUICK START ADVANCED GUIDES React QUICK START Installation Hello World Introducing JSX Components and Props

More information

AJAX and JSON. Day 8

AJAX and JSON. Day 8 AJAX and JSON Day 8 Overview HTTP as a data exchange protocol Components of AJAX JSON and XML XMLHttpRequest Object Updating the HTML document References Duckett, chapter 8 http://www.w3schools.com/ajax/default.asp

More information

Node.js. Node.js Overview. CS144: Web Applications

Node.js. Node.js Overview. CS144: Web Applications Node.js Node.js Overview JavaScript runtime environment based on Chrome V8 JavaScript engine Allows JavaScript to run on any computer JavaScript everywhere! On browsers and servers! Intended to run directly

More information

Computing Fundamentals Advanced functions & Recursion

Computing Fundamentals Advanced functions & Recursion Computing Fundamentals Advanced functions & Recursion Salvatore Filippone salvatore.filippone@uniroma2.it 2014 2015 (salvatore.filippone@uniroma2.it) Recursion 2014 2015 1 / 14 Anonymous functions Useful

More information

Advanced React JS + Redux Development

Advanced React JS + Redux Development Advanced React JS + Redux Development Course code: IJ - 27 Course domain: Software Engineering Number of modules: 1 Duration of the course: 40 astr. hours / 54 study 1 hours Sofia, 2016 Copyright 2003-2016

More information

Objectives for this class meeting. 1. Conduct review of core concepts concerning contracts and pre/post conditions

Objectives for this class meeting. 1. Conduct review of core concepts concerning contracts and pre/post conditions CSE1720 Click to edit Master Week text 01, styles Lecture 02 Second level Third level Fourth level Fifth level Winter 2015! Thursday, Jan 8, 2015 1 Objectives for this class meeting 1. Conduct review of

More information

ASYNCHRONOUS PROGRAMMING IN C# 5 WITHOUT USE OF MULTIPLE THREADS

ASYNCHRONOUS PROGRAMMING IN C# 5 WITHOUT USE OF MULTIPLE THREADS ASYNCHRONOUS PROGRAMMING IN C# 5 WITHOUT USE OF MULTIPLE THREADS Aleš Keprt Department of Informatics, Moravian College Olomouc ales.keprt@mvso.cz ABSTRACT: Asynchrony is a situation when multiple things

More information

Module 5 JavaScript, AJAX, and jquery. Module 5. Module 5 Contains 2 components

Module 5 JavaScript, AJAX, and jquery. Module 5. Module 5 Contains 2 components Module 5 JavaScript, AJAX, and jquery Module 5 Contains 2 components Both the Individual and Group portion are due on Monday October 30 th Start early on this module One of the most time consuming modules

More information

Java SE7 Fundamentals

Java SE7 Fundamentals Java SE7 Fundamentals Introducing the Java Technology Relating Java with other languages Showing how to download, install, and configure the Java environment on a Windows system. Describing the various

More information

Introduction to JavaScript p. 1 JavaScript Myths p. 2 Versions of JavaScript p. 2 Client-Side JavaScript p. 3 JavaScript in Other Contexts p.

Introduction to JavaScript p. 1 JavaScript Myths p. 2 Versions of JavaScript p. 2 Client-Side JavaScript p. 3 JavaScript in Other Contexts p. Preface p. xiii Introduction to JavaScript p. 1 JavaScript Myths p. 2 Versions of JavaScript p. 2 Client-Side JavaScript p. 3 JavaScript in Other Contexts p. 5 Client-Side JavaScript: Executable Content

More information

Why Deprecating async() is the Worst of all Options

Why Deprecating async() is the Worst of all Options Doc No: WG21 N3780 Date: 2013-09-26 Reply to: Nicolai Josuttis (nico@josuttis.de) Subgroup: SG1 Concurrency Prev. Version: none Why Deprecating async() is the Worst of all Options The concurrency working

More information

JavaScript Programming

JavaScript Programming JavaScript Programming Course ISI-1337B - 5 Days - Instructor-led, Hands on Introduction Today, JavaScript is used in almost 90% of all websites, including the most heavilytrafficked sites like Google,

More information

Session 18. jquery - Ajax. Reference. Tutorials. jquery Methods. Session 18 jquery and Ajax 10/31/ Robert Kelly,

Session 18. jquery - Ajax. Reference. Tutorials. jquery Methods. Session 18 jquery and Ajax 10/31/ Robert Kelly, Session 18 jquery - Ajax 1 Tutorials Reference http://learn.jquery.com/ajax/ http://www.w3schools.com/jquery/jquery_ajax_intro.asp jquery Methods http://www.w3schools.com/jquery/jquery_ref_ajax.asp 2 10/31/2018

More information

A Model for Reasoning About JavaScript Promises

A Model for Reasoning About JavaScript Promises A Model for Reasoning About JavaScript Promises MAGNUS MADSEN, University of Waterloo, Canada ONDŘEJ LHOTÁK, University of Waterloo, Canada FRANK TIP, Northeastern University, USA In JavaScript programs,

More information

Manoj Kumar- From Call back's hell to using Async Await: Automated testing with JavaScript

Manoj Kumar- From Call back's hell to using Async Await: Automated testing with JavaScript Manoj Kumar- From Call back's hell to using Async Await: Automated testing with JavaScript ManojKumar: Welcome everyone again. We are here to see about a primer on Selenium WebDriver JavaScript and Protractor

More information

Asynchronous JS. SWE 432, Fall Web Application Development

Asynchronous JS. SWE 432, Fall Web Application Development Asynchronous JS SWE 432, Fall 2018 Web Application Development Review: Asynchronous Synchronous: Make a function call When function call returns, the work is done Asynchronous: Make a function call Function

More information

Reactive Java: Promises and Streams with Reakt. Geoff Chandler and Rick Hightower

Reactive Java: Promises and Streams with Reakt. Geoff Chandler and Rick Hightower Reactive Java: Promises and Streams with Reakt Geoff Chandler and Rick Hightower What is Reakt in 30 seconds! Reakt General purpose library for callback coordination and streams Implements JavaScript

More information

Microservices with Node.js

Microservices with Node.js Microservices with Node.js Objectives In this module we will discuss: Core Node.js concepts Node Package Manager (NPM) The Express Node.js package The MEAN stack 1.1 What is Node.js? Node.js [ https://nodejs.org/

More information

CS 3 Introduction to Software Engineering. 3: Exceptions

CS 3 Introduction to Software Engineering. 3: Exceptions CS 3 Introduction to Software Engineering 3: Exceptions Questions? 2 Objectives Last Time: Procedural Abstraction This Time: Procedural Abstraction II Focus on Exceptions. Starting Next Time: Data Abstraction

More information

JavaScript and MVC Frameworks FRONT-END ENGINEERING

JavaScript and MVC Frameworks FRONT-END ENGINEERING FRONT-END ENGINEERING Introduction & History Introduction JavaScript is an incredible language to learn for anyone interested in getting into programming. It is the only programing language that can run

More information

Pro JavaScript. Development. Coding, Capabilities, and Tooling. Den Odell. Apress"

Pro JavaScript. Development. Coding, Capabilities, and Tooling. Den Odell. Apress Pro JavaScript Development Coding, Capabilities, and Tooling Den Odell Apress" Contents J About the Author About the Technical Reviewers Acknowledgments Introduction xv xvii xix xxi Chapter 1: Object-Oriented

More information

A Framework for Creating Distributed GUI Applications

A Framework for Creating Distributed GUI Applications A Framework for Creating Distributed GUI Applications Master s Project Report Derek Snyder May 15, 2006 Advisor: John Jannotti Introduction Creating distributed graphical user interface (GUI) applications

More information

CSCE 120: Learning To Code

CSCE 120: Learning To Code CSCE 120: Learning To Code Module 11.0: Consuming Data I Introduction to Ajax This module is designed to familiarize you with web services and web APIs and how to connect to such services and consume and

More information

JavaScript. Training Offer for JavaScript Introduction JavaScript. JavaScript Objects

JavaScript. Training Offer for JavaScript Introduction JavaScript. JavaScript Objects JavaScript CAC Noida is an ISO 9001:2015 certified training center with professional experience that dates back to 2005. The vision is to provide professional education merging corporate culture globally

More information

RESTful APIs ECS 189 WEB PROGRAMMING. Browser s view. Browser s view. Browser s view. Browser s view. Which will It be for photobooth?

RESTful APIs ECS 189 WEB PROGRAMMING. Browser s view. Browser s view. Browser s view. Browser s view. Which will It be for photobooth? RESTful APIs ECS 189 WEB PROGRAMMING 5/19! We re implementing what is called a RESTful API! ReST stands for representational state transfer! The term was coined in 2000 by Roy Fielding, who at the time

More information

Notes on JavaScript (aka ECMAScript) and the DOM

Notes on JavaScript (aka ECMAScript) and the DOM Notes on JavaScript (aka ECMAScript) and the DOM JavaScript highlights: Syntax and control structures superficially resemble Java/C/C++ Dynamically typed Has primitive types and strings (which behave more

More information

quiz 1 details wed nov 17, 1pm see handout for locations covers weeks 0 through 10, emphasis on 7 onward closed book bring a , 2-sided cheat she

quiz 1 details wed nov 17, 1pm see handout for locations covers weeks 0 through 10, emphasis on 7 onward closed book bring a , 2-sided cheat she quiz 1 details wed nov 17, 1pm see handout for locations covers weeks 0 through 10, emphasis on 7 onward closed book bring a 8.5 11, 2-sided cheat sheet 75 minutes 15% of final grade resources old quizzes

More information

Course Details. Skills Gained. Who Can Benefit. Prerequisites. View Online URL:

Course Details. Skills Gained. Who Can Benefit. Prerequisites. View Online URL: Specialized - Mastering jquery Code: Lengt h: URL: TT4665 4 days View Online Mastering jquery provides an introduction to and experience working with the JavaScript programming language in the environment

More information

Getting Started with IBM Bluemix Hands-On Workshop. Module 6a: Services

Getting Started with IBM Bluemix Hands-On Workshop. Module 6a: Services Hands-On Workshop Module 6a: Services Workshop overview In this workshop, you will: Create a Cloudant service that extends the Fizzbuzz application Create a user-defined service that is local to your

More information

JavaScript Specialist v2.0 Exam 1D0-735

JavaScript Specialist v2.0 Exam 1D0-735 JavaScript Specialist v2.0 Exam 1D0-735 Domain 1: Essential JavaScript Principles and Practices 1.1: Identify characteristics of JavaScript and common programming practices. 1.1.1: List key JavaScript

More information

MANAGING ASYNCHRONY. An Application Perspective

MANAGING ASYNCHRONY. An Application Perspective MANAGING ASYNCHRONY An Application Perspective TYPES OF ASYNCHRONY DETERMINISTIC ORDER. (I/O) NON-DETERMINISTIC ORDER. (USER EVENTS) THESE ARE DIFFERENT. Because both are "events", we reach for the same

More information

Exception Namespaces C Interoperability Templates. More C++ David Chisnall. March 17, 2011

Exception Namespaces C Interoperability Templates. More C++ David Chisnall. March 17, 2011 More C++ David Chisnall March 17, 2011 Exceptions A more fashionable goto Provides a second way of sending an error condition up the stack until it can be handled Lets intervening stack frames ignore errors

More information

The compiler is spewing error messages.

The compiler is spewing error messages. Appendix B Debugging There are a few different kinds of errors that can occur in a program, and it is useful to distinguish between them in order to track them down more quickly. Compile-time errors are

More information

User Interaction: jquery

User Interaction: jquery User Interaction: jquery Assoc. Professor Donald J. Patterson INF 133 Fall 2012 1 jquery A JavaScript Library Cross-browser Free (beer & speech) It supports manipulating HTML elements (DOM) animations

More information

THE PRAGMATIC INTRO TO REACT. Clayton Anderson thebhwgroup.com WEB AND MOBILE APP DEVELOPMENT AUSTIN, TX

THE PRAGMATIC INTRO TO REACT. Clayton Anderson thebhwgroup.com WEB AND MOBILE APP DEVELOPMENT AUSTIN, TX THE PRAGMATIC INTRO TO REACT Clayton Anderson thebhwgroup.com WEB AND MOBILE APP DEVELOPMENT AUSTIN, TX REACT "A JavaScript library for building user interfaces" But first... HOW WE GOT HERE OR: A BRIEF

More information