Abstraction and Functions

Slides:



Advertisements
Similar presentations
MWD1001 Website Production Using JavaScript with Forms.
Advertisements

1 CSC 533: Organization of Programming Languages Spring 2007 Java vs. JavaScript  JavaScript design goals  examples input/output, functions, numbers.
1 CSC 121 Computers and Scientific Thinking David Reed Creighton University Chapter 9 Abstraction and User-Defined Functions.
Lesson 4: Formatting Input Data for Arithmetic
JSP: JavaServer Pages Juan Cruz Kevin Hessels Ian Moon.
Chapter 20 Thinking Big: Functions. Copyright © 2006 Pearson Addison-Wesley. All rights reserved Anatomy of a Function Functions are packages for.
 Monday, 9/30/02, Slide #1 CS106 Introduction to CS1 Monday, 9/30/02  QUESTIONS (on HW02, etc.)??  Today: Libraries, program design  More on Functions!
CIS101 Introduction to Computing Week 11. Agenda Your questions Copy and Paste Assignment Practice Test JavaScript: Functions and Selection Lesson 06,
CM143 - Web Week 2 Basic HTML. Links and Image Tags.
Introduction to JavaScript for Python Programmers
JAVASCRIPT HOW TO PROGRAM -2 DR. JOHN P. ABRAHAM UTPA.
JavaScript Teppo Räisänen LIIKE/OAMK HTML, CSS, JavaScript HTML defines the structure CSS defines the layout JavaScript is used for scripting It.
 2003 Prentice Hall, Inc. All rights reserved. CHAPTER 3 JavaScript 1.
Introduction to Applets CS 3505 Client Side Scripting with applets.
JavaScript Professor Robin Burke. 2 Outline Quiz Tables JavaScript.
 2003 Prentice Hall, Inc. All rights reserved. CHAPTER 3 JavaScript 1.
Dynamic Web Pages & JavaScript. Dynamic Web Pages Dynamic = Change Dynamic Web Pages are web pages that change. More than just moving graphics around.
1 Functions Lecfture Abstraction abstraction is the process of ignoring minutiae and focusing on the big picture in modern life, we are constantly.
Functions, Procedures, and Abstraction Dr. José M. Reyes Álamo.
Java Script User Defined Functions. Java Script  You can define your own JavaScript functions. Such functions are called user- defined, as opposed to.
CSC 121 Computers and Scientific Thinking David Reed Creighton University 1 Abstraction and User-Defined Functions.
THINKING BIG Abstraction and Functions chapter 6 Modified by Dr. Paul Mullins for CPSC 130, F05.
JavaScript III Functions and Abstraction. 2 JavaScript so far statements assignment function calls data types numeric string boolean expressions variables.
Created by, Author Name, School Name—State FLUENCY WITH INFORMATION TECNOLOGY Skills, Concepts, and Capabilities.
Introduction to Programming JScript Six Scripting functions Discuss functions Password Example.
1 A Balanced Introduction to Computer Science David Reed, Creighton University ©2005 Pearson Prentice Hall ISBN X Chapter 4 JavaScript and.
Procedural Programming Criteria: P2 Task: 1.2 Thomas Jazwinski.
Chapter 2: Variables, Functions, Objects, and Events JavaScript - Introductory.
Basics of Most C++ Programs // Programmer: Clayton Price date: 9/4/ // File: fahr2celc.cpp 03. // Purpose:
Javascript JavaScript is what is called a client-side scripting language:  a programming language that runs inside an Internet browser (a browser is also.
Javascript Overview. What is Javascript? May be one of the most popular programming languages ever Runs in the browser, not on the server All modern browsers.
Understanding JavaScript and Coding Essentials Lesson 8.
JavaScript Introduction and Background. 2 Web languages Three formal languages HTML JavaScript CSS Three different tasks Document description Client-side.
CSC 121 Computers and Scientific Thinking Fall Interactive Web Pages.
Abstraction and Functions Professor Robin Burke. 2 Outline Quiz JavaScript review Abstraction Function Definitions purpose syntax Functions return value.
Expressions and Data Types Professor Robin Burke.
JavaScript 101 Lesson 6: Introduction to Functions.
© 2010 Robert K. Moniot1 Chapter 6 Introduction to JavaScript.
Precedence Operators Error Types
Introduction to Computers
>> JavaScript: Location, Functions and Objects
Python Programming Module 3 Functions Python Programming, 2/e.
Learning to Program D is for Digital.
Intro to JavaScript CS 1150 Spring 2017.
Programming the Web using XHTML and JavaScript
4. Javascript Pemrograman Web I Program Studi Teknik Informatika
JavaScript.
User-Defined Functions
Chapter 7 - JavaScript: Introduction to Scripting
JavaScript Introduction
CT Web Development, Colorado State University
Introduction to Computers
Functions, Procedures, and Abstraction
JavaScript: Introduction to Scripting
Introduction to JavaScript for Python Programmers
Engineering Computation with MATLAB
SME1013 PROGRAMMING FOR ENGINEERS
CSC128 FUNDAMENTALS OF COMPUTER PROBLEM SOLVING
SME1013 PROGRAMMING FOR ENGINEERS
JavaScript MCS/BCS.
Chapter 20: Programming Functions
Abstraction and User-Defined Functions
Introduction to Problem Solving and Programming
Chapter 7 - JavaScript: Introduction to Scripting
Chapter 7 - JavaScript: Introduction to Scripting
Chapter 9 Abstraction and User-Defined Functions
JavaScript.
Chapter 7 Abstraction and User-Defined Functions
Chapter 7 - JavaScript: Introduction to Scripting
Chapter 5 JavaScript Numbers and Expressions
Presentation transcript:

Abstraction and Functions Professor Robin Burke

Outline Function Definitions Functions Function libraries syntax return value multiple parameters local variables Function libraries

Function definition syntax function FahrToCelsius (tempInFahr) { return (5/9) * (tempInFahr – 32); } declaration start function name parameter names start of body function body end of body

Scope With functions Local Global levels of interpretation what happens inside of a function Global what happens outside of the function

Renamed example 4 animal cow OldMacVerse sound moo global document.write (...) animal cow OldMacVerse sound moo OldMacVerse (critter, noise); ("duck", "quack"); global "testmac.html" critter cow noise moo

Libraries We can define a group of functions Separate file usually related Separate file .js extension Load using script tag <script type="text/javascript" src="random.js" /> Call functions from page

Example random.js pick4.html convert.js ctof2.html ftok.html

Debugging examples

Computational problem-solving Initial conditions what do we know? what is the input? Output what will the solution look like? Resources what pieces already exist?

Problem decomposition Identify steps that will lead to a solution Decompose each step into steps small enough that they can be implemented Multiple stages of decomposition may be necessary

Pseudocode Programming language is too specific requires that you make low-level decisions Useful to describe steps of computation Pseudocode describe computation without actually writing the program

Example A page that convert Fahrenheit to Celcius

Decomposition 1 Initial conditions Output Resources Temp F input by user Output appropriate HTML with Celsius temperature Resources conversion formula

Decomposition 2 Steps Not quite pseudocode get input calculate conversion output HTML Not quite pseudocode not operations that Javascript can do can be decomposed further

Decomposition 3 get input calculate conversion output HTML prompt user for temp in F calculate conversion temp in C is 5/9 temp in F - 32 output HTML write temp F to page write temp C to page

Pseudocode Could be realized in multiple programming languages prompt user for temp in F temp in C is 5/9 temp in F - 32 write temp F to page write temp C to page Could be realized in multiple programming languages although only a few can be used as web scripting languages

New problem Get height and width from user Display a table (single cell) of this size with the dimensions inside

Next class Events Reading Ch. 9