Presentation is loading. Please wait.

Presentation is loading. Please wait.

Week 5 LBSC 690 Information Technology

Similar presentations


Presentation on theme: "Week 5 LBSC 690 Information Technology"— Presentation transcript:

1 Week 5 LBSC 690 Information Technology
Programming Week 5 LBSC 690 Information Technology

2 Software Software models aspects of reality Examples
Input and output represent the state of the world Software describes how the two are related Examples Ballistic computations Alta Vista Microsoft Word

3 Types of Software Compilers and interpreters
Application programs (e.g., Powerpoint) What you normally think of as a ``program’’ Compilers and interpreters Programs used to write other programs Operating system (e.g., Windows XP) Manages display, CPU, memory, disk, tape, Embedded program (e.g., BIOS) Permanent software inside some device

4 Discussion Point: The Mythical Person-Month
If it would take one person three months, why does it take four people SIX months? The original estimate might have been too low Partitioning strategy led to a long “critical path” Training new people takes each some time More people means more communications

5 Training Time Simple Example Learning the specification takes time
Full time person = 2,000 hours/year Part time person = 288 hours per year No training  7 part time people With training  10 part time people Learning the specification takes time Learning organizational “rules” takes longer!

6 Communications Sort of like continuous training
Who needs to know what I just learned? Can be minimized by good partitioning Limit the number of interfaces Can be facilitated by computers Asynchronous communication techniques , private newsgroups, voice mail

7 Estimating Completion Time
Rules of thumb 1/3 specification 1/6 coding 1/2 test planning, testing, and fixing! Add time for coding to learn as you go, but don’t take time away from the other parts! Reread the section on “gutless estimating” if you are tempted

8 Programming Languages
Used to specify every detail of the model Special purpose Able to specify an entire class of models Spreadsheets (Excell, Quatro Pro, ...) Databases (Access, Paradox, Oracle, ...) General purpose Able to specify any possible model Pascal, C, Java, JavaScript, Perl, ...

9 History of Programming
Machine language Language that machine can understand Machine dependent Zeroes and Ones Assembly language Assembler changes names to machine code High-level languages Compiler/Interpreter translates to machine language Machine independent FORTRAN, COBOL, C, C++, Javascript

10 Machine Language Everything is a binary number For instance
Operations Data For instance might represent “add” first number to add second number to add

11 Assembly Language Symbolic instruction codes and addresses
Symbolic instruction code “ADD” Symbolic address “SUM1” For instance ADD , SUM1

12 High level Languages Procedural (modular) Programming
Group instructions into meaningful abstractions C, Pascal, Perl Object oriented programming Group “data” and “methods” into “objects” Naturally represents responses to events C++, Java, JavaScript

13 Object Models Represent things in the world as “objects”
Simplest objects are “variables” Represented with a name (n, teacher, …) May be assigned a value (n=4, teacher=“Daqing”, …) Represent actions with “methods” Simplest methods are “operations” Represented with a symbol (+, -, *, /, …) “Classes” group objects with methods Classes model how kinds of things behave Objects are instances of classes

14 Data Types Boolean: true/false Numbers: 5, 9, 3.1415926
Strings: “Hello World” Variables: Temperature, F, Celsius, Class: Temperature Instance: CollegeParkTemperature Method: toCelsius(F)

15 Arrays A set of elements Each element is assigned an index
For example, the number of days in each month Each element is assigned an index A number used to refer to that element For example, x[4] is the fifth element - count from zero Arrays and loops work naturally togther

16 Operations and Assignments
-x reverse the sign of x (negation) Add 6 and 5 (numeric) “Hello” + “World” Concatenate two strings 2.1 * 3 Multiply two values x++ increase value of x by 1 x = 5 set the value of x to be 5 x += y x = x + y x *= 5 x = x * 5

17 Comparisons x == y returns true if x and y are equal
x != y returns true if x and y are not equal x > y returns true if x is greater than y x <= y returns true if x is smaller than or equal to y x && y returns true if both x and y are true x || y returns true if either x or y is true !x returns true if x is false

18 toCelsius? Function toCelsius(F) { Celsius = 5/9 * (F-32)
return Celsius }

19 Statements Simple assignment statements
Celsius = 5/9 * (F-32) Statements that invoke a method Temperature.toCelsius(104) Return a value from a method return Celsius

20 Basic Control Structures
Sequential Control Structure Conditional Selection Control Structure Repetition Control Structure

21 Sequential Control Structure
b = 3 c = a * b

22 Conditional Selection Control Structure
if (gender == “male”) { greeting = “Hello, Sir” } else { greeting = “Hello, Madam”

23 Repetition Control Structure
Program Example 1: n = 1 while ( n <= 10) { document.writeln(n) n++ } Program 2: For (n = 1; n <= 10; n++) {

24 Programming for the Web
Common Gateway Interface (CGI) [Server side] Forms encode field values into a URL CGI passes field values to a Perl program Program generates a web page as a response JavaScript [Client-side, interpreted] Human-readable “source code” sent to the browser Web browser runs the program Java applets [Client-side, compiled] Machine-readable “bytecode” sent to browser

25 What is JavaScript Embedded in html (interpreted), not compiled
To make we pages more interactive Java Script is NOT Java Minimal data typing and modularity No graphics, no formal classes

26 JavaScript <HTML> <HEAD>
<TITLE>My first script</TITLE> </HEAD> <BODY BGCOLOR=WHITE> <H1> <SCRIPT LANGUAGE=JAVASCRIPT TYPE="TEXT/JAVASCRIPT"> document.write("Hello, world!") </SCRIPT> </H1> </BODY></HTML> Try it at

27 Handling Events Events: Use event handlers to response events
actions that users perform while visiting the page Use event handlers to response events Event handlers triggered by events Examples of event handlers onMouseover: the mouse moved over an object onMouseout: the mouse moved off an object onClick: the user clicked on an object

28 A Simple rollover.html Click rollover.html
Move mouse over and away the arrow View source arrowRed, arrowBlue are variables (“new Image”) arrowRed.src specifies the value Event handlers “onMouseover” and “onMouseoff” Name of the image is defined by NAME = “arrow” <!– Hide script from old browsers … If (document.images) { … to test browser function

29 Using Function Repetitive tasks => functions
Load multirollover1.html and multirollover2.html View sources of the two files Function chgImg handle changing images for all Program is shorter and clearer document.textField equal to document[“textField”]

30 Hands on Point: Adopt a JavaScript Program
Launch a web browser Internet Explorer would be the best choice See how it behaves if you are 13 (or 65) View source and read the program Save a local copy Make some changes and see how it works

31 JavaScript and Cookies
cookieName=cookieValue; expires=expirationDateGMT; path=URLpath; domain=siteDomain Combine cookie and javascript can do many things Set your user name Read your user name Use cookies as counters


Download ppt "Week 5 LBSC 690 Information Technology"

Similar presentations


Ads by Google