SlideShare a Scribd company logo
1
CS101 Introduction to Computing
Lecture 44Programming Methodology
(Web Development Lecture 15)
2
During the last lecture we discussed
Graphics & Animation
• We became able to add and manipulate
images and simple animations to a Web page
3
Images in HTML
• It is quite straight forward to include gif and jpg
images in an html Web page using the <IMG>
tag
• Format: <IMG src=URL, alt=text
height=pixels width=pixels
align="bottom|middle|top">
• Plea: Don’t use images just for the sake of it!
4
Images in JavaScript
• Images in JavaScript can be manipulated in
many ways using the built-in object, Image
• Properties: name, border, complete, height,
width, hspace, vspace, lowsrc, src
• Methods: None
• Event handlers: onAbort, onError, onLoad, etc.
5
Image Preloading
• The primary use for an Image object is to
download an image into the cache before it is
actually needed for display
• This technique can be used to create smooth
animations or to display one of several images
based on the requirement
6
The Image Pre-Loading Process
1. An instance of the Image object is created
using the new keyword
2. The src property of this instance is set equal to
the filename of the image to be pre-loaded
3. That step starts the down-loading of the image
into the cache without actually displaying it
4. When a pre-loaded image is required to be
displayed, the src property of the displayed
image is set to the src property of the pre-
fetched image
7
Animated Gifs
• We could have saved the 16 gif images of the
previous example in a single file in the form of
an animated gif, and then used it in a regular
<IMG> tag to display a moving image
• However, JavaScript provides better control
over the sequencing and the gap between the
individual images
• Example
8
Today’s Goals
(Programming Methodology)
• To understand effective programming practices
that result in the development of correct
programs with minimum effort
• To become familiar with testing & debugging
9
programmingprogramming
methodologymethodology??
The process used by
an individual or a team
for developing
programs
10
programmingprogramming
methodologymethodology??
goodgoodA methodology that
enables the lowest-cost
and on-schedule
development of programs
that are correct, easy to
maintain & enhance
11
correctcorrect
programprogram??
A program
with correct
syntax &
semantics
12
readablereadable
programprogram??
A program that is
easy to read &
understand, and
therefore, easy to
maintain & enhance
13
swapFlag = true ;
while ( swapFlag == true ) {
swapFlag = false ;
for ( k = 0 ; k < ht.length - 1 ; k++ ) {
if ( ht[ k ] < ht[ k + 1 ] ) {
temp = ht[ k + 1 ] ;
ht[ k + 1 ] = ht[ k ] ;
ht[ k ] = temp ;
swapFlag = true ;
}
}
}
How can we make it more readable?
What is its most complex aspect?
Bubble
Sort
14
for ( j = 0 ; j < 100000 ; j++ ) {
for ( k = 0 ; k < ht.length - 1 ; k++ ) {
if ( ht[ k ] < ht[ k + 1 ] ) {
temp = ht[ k + 1 ] ;
ht[ k + 1 ] = ht[ k ] ;
ht[ k ] = temp ;
}
}
}
15
Readable programs are:Readable programs are:
-- moremore readablereadable
- efficient- efficient enoughenough
16
guidelines
17
Design Guidelines
• Break your code down into short and simple
functions (e.g. take the 3 swap statements out
from the last example and put them into a
function of their own)
• Do not use global variables
18
Coding Guidelines
• Always use semicolons to end statements
• Indent blocks of code (2 to 5 spaces)
• Identifiers:
– Use the camelBack scheme
– Make them descriptive but concise
– Variables: nouns
– Functions: verbs
• Comment liberally
19
Comments let
the code speak
for itself!
20
Guidelines for Developing Short Programs
1. Read, understand
the problem
2. Do you have all the
required data?
No: Get it
Else assume it.
State it explicitly
21
Example: Problem Statement
• Develop a Web page that displays an order
taking form
• It takes the number of items required for each
product, multiplies with the prices, sums them
up, adds the GST, and displays the total value
of the order
22
Guidelines for Developing Short Programs
1. Read, understand
the problem
2. Do you have all the
required data?
No: Get it
Else assume it.
State it explicitly
3. Do the design
23
24
Developing Short Programs
1. Read, understand
the problem
2. Do you have all the
required data?
No: Get it
Else assume it.
State it explicitly
3. Do the design
4. Write test cases
25
26
Developing Short Programs
1. Read, understand
the problem
2. Do you have all the
required data?
No: Get it
Else assume it.
State it explicitly
3. Do the design
4. Write test cases
5. Write the code on a
piece of paper
6. Hand-check it
7. Type it in
8. Run & check it on
test cases
9. Errors? fix & redo 9
Done!
27
Design & Code Reviews
• Probably the most efficient way of improving
the a program
• Being humans, at time we see what is
supposed to be there instead of what is actually
there
• Another pair of eyeballs may not have the
same problem, especially if they were not
involved in building the design or code
28
Two Popular Review Methods
1. Give the problem statement, design, and code
(that includes all assumptions) to a peer, and
ask him/her to see if things have been done
properly
2. Walk a peer or a group of peers through the
problem, the design, and the code yourself
Which of the two is better?
29
Is it possible to
write defect-
free programs?
30
Is it even advisable
to attempt writing
programs that are
free of defects?
31
Testing & Debugging
• Testing: The tasks performed to determine the
existence of defects
• Debugging: The tasks performed to detect the
exact location of defects
• Defects are also called bugs or errors
• Let us now look at one of their classifications
32
Types of Errors
• Syntax errors
• Semantic errors
• Run-time errors
Syntax Errors
• They are caused by the code that somehow
violates the rules of the language
• Easy to detect and fix errors
• The browser stops code interpretation on
detecting one of these
• Examples:
– a = b + * c ;
– receiver = reciever + 2
Syntax
error?
34
Semantic Errors
• Occur when a statement executes and has an
effect not intended by the programmer
• Hard to detect during normal testing
• Often times occur only in unusual & infrequent
circumstances
• The ‘+’ operator often results in unintended
consequences. Remedy: Convert, before use
35
Run-Time Errors
• Occur when the program is running and tries to
do something that is against the rules
• Example: Accessing a non-existent variable,
property, method, object, etc (e.g. a method
name is misspelled)
• Sources of these can be determined by a
careful reading of the code, but unfortunately,
not always!
36
Debugging
37
Tools:
Internet
Options…:
Advanced:
38
name = "Bhola ;
Syntax Error
39
checkPulse( ) ;
Run-time Error
40
x = 1.3 ;
x.upperCase( ) ;
Run-time Error
41
income = document.myForm.salary.value +
document.myForm.bonus.value ;
Semantic Error
42
coMmon
misstakess
43
if ( today = “holiday” )
mood = “good” ;
44
if ( today == “holiday” ) ;
mood = “good” ;
45
if ( today == “holiday” || weather == “OK”
mood = “excellent” ;
46
function doThis ( tiger ) {
box[ 0 ] = tiger ;
x = box[ 0 ] ;
return x ;
47
box = new array( 10 ) ;
48
box = new Array( 10 ) ;
box( 0 ) = 43 ;
49
Helpful Editors
• Using smart editors (e.g. DreamWeaver, nedit)
can help in avoiding many types of syntax
errors
• They can, for example:
– Automatically color different parts of statements in
different colors, e.g. comments in Gray, strings in
Green, HTML tags in Blue
– Auto indent
– Visually indicate the presence of mismatched
parentheses, curly braces or square brackets
50
During Today’s Lecture …
• We looked at a few effective programming
practices that result in the development of
correct programs with minimum effort
• We also became familiar with testing &
debugging
51
Final Lecture:
Review & Wrap-Up
• To review a selection from the interesting ideas
that we explored over the last 44 lectures

More Related Content

Viewers also liked

CS101- Introduction to Computing- Lecture 31
CS101- Introduction to Computing- Lecture 31CS101- Introduction to Computing- Lecture 31
CS101- Introduction to Computing- Lecture 31
Bilal Ahmed
 
CS201- Introduction to Programming- Lecture 11
CS201- Introduction to Programming- Lecture 11CS201- Introduction to Programming- Lecture 11
CS201- Introduction to Programming- Lecture 11
Bilal Ahmed
 
CS201- Introduction to Programming- Lecture 24
CS201- Introduction to Programming- Lecture 24CS201- Introduction to Programming- Lecture 24
CS201- Introduction to Programming- Lecture 24
Bilal Ahmed
 
CS201- Introduction to Programming- Lecture 06
CS201- Introduction to Programming- Lecture 06CS201- Introduction to Programming- Lecture 06
CS201- Introduction to Programming- Lecture 06
Bilal Ahmed
 
CS201- Introduction to Programming- Lecture 14
CS201- Introduction to Programming- Lecture 14CS201- Introduction to Programming- Lecture 14
CS201- Introduction to Programming- Lecture 14
Bilal Ahmed
 
MGT101 - Financial Accounting- Lecture 33
MGT101 - Financial Accounting- Lecture 33MGT101 - Financial Accounting- Lecture 33
MGT101 - Financial Accounting- Lecture 33
Bilal Ahmed
 
ENG101- English Comprehension- Lecture 42
ENG101- English Comprehension- Lecture 42ENG101- English Comprehension- Lecture 42
ENG101- English Comprehension- Lecture 42
Bilal Ahmed
 
CS201- Introduction to Programming- Lecture 33
CS201- Introduction to Programming- Lecture 33CS201- Introduction to Programming- Lecture 33
CS201- Introduction to Programming- Lecture 33
Bilal Ahmed
 
CS201- Introduction to Programming- Lecture 22
CS201- Introduction to Programming- Lecture 22CS201- Introduction to Programming- Lecture 22
CS201- Introduction to Programming- Lecture 22
Bilal Ahmed
 
MTH101 - Calculus and Analytical Geometry- Lecture 44
MTH101 - Calculus and Analytical Geometry- Lecture 44MTH101 - Calculus and Analytical Geometry- Lecture 44
MTH101 - Calculus and Analytical Geometry- Lecture 44
Bilal Ahmed
 
CS201- Introduction to Programming- Lecture 27
CS201- Introduction to Programming- Lecture 27CS201- Introduction to Programming- Lecture 27
CS201- Introduction to Programming- Lecture 27
Bilal Ahmed
 
ENG101- English Comprehension- Lecture 30
ENG101- English Comprehension- Lecture 30ENG101- English Comprehension- Lecture 30
ENG101- English Comprehension- Lecture 30
Bilal Ahmed
 
ENG101- English Comprehension- Lecture 43
ENG101- English Comprehension- Lecture 43ENG101- English Comprehension- Lecture 43
ENG101- English Comprehension- Lecture 43
Bilal Ahmed
 
CS201- Introduction to Programming- Lecture 16
CS201- Introduction to Programming- Lecture 16CS201- Introduction to Programming- Lecture 16
CS201- Introduction to Programming- Lecture 16
Bilal Ahmed
 
ENG101- English Comprehension- Lecture 28
ENG101- English Comprehension- Lecture 28ENG101- English Comprehension- Lecture 28
ENG101- English Comprehension- Lecture 28
Bilal Ahmed
 
ENG101- English Comprehension- Lecture 35
ENG101- English Comprehension- Lecture 35ENG101- English Comprehension- Lecture 35
ENG101- English Comprehension- Lecture 35
Bilal Ahmed
 
ENG101- English Comprehension- Lecture 24
ENG101- English Comprehension- Lecture 24ENG101- English Comprehension- Lecture 24
ENG101- English Comprehension- Lecture 24
Bilal Ahmed
 
CS101- Introduction to Computing- Lecture 38
CS101- Introduction to Computing- Lecture 38CS101- Introduction to Computing- Lecture 38
CS101- Introduction to Computing- Lecture 38
Bilal Ahmed
 
CS201- Introduction to Programming- Lecture 34
CS201- Introduction to Programming- Lecture 34CS201- Introduction to Programming- Lecture 34
CS201- Introduction to Programming- Lecture 34
Bilal Ahmed
 
ENG101- English Comprehension- Lecture 23
ENG101- English Comprehension- Lecture 23ENG101- English Comprehension- Lecture 23
ENG101- English Comprehension- Lecture 23
Bilal Ahmed
 

Viewers also liked (20)

CS101- Introduction to Computing- Lecture 31
CS101- Introduction to Computing- Lecture 31CS101- Introduction to Computing- Lecture 31
CS101- Introduction to Computing- Lecture 31
 
CS201- Introduction to Programming- Lecture 11
CS201- Introduction to Programming- Lecture 11CS201- Introduction to Programming- Lecture 11
CS201- Introduction to Programming- Lecture 11
 
CS201- Introduction to Programming- Lecture 24
CS201- Introduction to Programming- Lecture 24CS201- Introduction to Programming- Lecture 24
CS201- Introduction to Programming- Lecture 24
 
CS201- Introduction to Programming- Lecture 06
CS201- Introduction to Programming- Lecture 06CS201- Introduction to Programming- Lecture 06
CS201- Introduction to Programming- Lecture 06
 
CS201- Introduction to Programming- Lecture 14
CS201- Introduction to Programming- Lecture 14CS201- Introduction to Programming- Lecture 14
CS201- Introduction to Programming- Lecture 14
 
MGT101 - Financial Accounting- Lecture 33
MGT101 - Financial Accounting- Lecture 33MGT101 - Financial Accounting- Lecture 33
MGT101 - Financial Accounting- Lecture 33
 
ENG101- English Comprehension- Lecture 42
ENG101- English Comprehension- Lecture 42ENG101- English Comprehension- Lecture 42
ENG101- English Comprehension- Lecture 42
 
CS201- Introduction to Programming- Lecture 33
CS201- Introduction to Programming- Lecture 33CS201- Introduction to Programming- Lecture 33
CS201- Introduction to Programming- Lecture 33
 
CS201- Introduction to Programming- Lecture 22
CS201- Introduction to Programming- Lecture 22CS201- Introduction to Programming- Lecture 22
CS201- Introduction to Programming- Lecture 22
 
MTH101 - Calculus and Analytical Geometry- Lecture 44
MTH101 - Calculus and Analytical Geometry- Lecture 44MTH101 - Calculus and Analytical Geometry- Lecture 44
MTH101 - Calculus and Analytical Geometry- Lecture 44
 
CS201- Introduction to Programming- Lecture 27
CS201- Introduction to Programming- Lecture 27CS201- Introduction to Programming- Lecture 27
CS201- Introduction to Programming- Lecture 27
 
ENG101- English Comprehension- Lecture 30
ENG101- English Comprehension- Lecture 30ENG101- English Comprehension- Lecture 30
ENG101- English Comprehension- Lecture 30
 
ENG101- English Comprehension- Lecture 43
ENG101- English Comprehension- Lecture 43ENG101- English Comprehension- Lecture 43
ENG101- English Comprehension- Lecture 43
 
CS201- Introduction to Programming- Lecture 16
CS201- Introduction to Programming- Lecture 16CS201- Introduction to Programming- Lecture 16
CS201- Introduction to Programming- Lecture 16
 
ENG101- English Comprehension- Lecture 28
ENG101- English Comprehension- Lecture 28ENG101- English Comprehension- Lecture 28
ENG101- English Comprehension- Lecture 28
 
ENG101- English Comprehension- Lecture 35
ENG101- English Comprehension- Lecture 35ENG101- English Comprehension- Lecture 35
ENG101- English Comprehension- Lecture 35
 
ENG101- English Comprehension- Lecture 24
ENG101- English Comprehension- Lecture 24ENG101- English Comprehension- Lecture 24
ENG101- English Comprehension- Lecture 24
 
CS101- Introduction to Computing- Lecture 38
CS101- Introduction to Computing- Lecture 38CS101- Introduction to Computing- Lecture 38
CS101- Introduction to Computing- Lecture 38
 
CS201- Introduction to Programming- Lecture 34
CS201- Introduction to Programming- Lecture 34CS201- Introduction to Programming- Lecture 34
CS201- Introduction to Programming- Lecture 34
 
ENG101- English Comprehension- Lecture 23
ENG101- English Comprehension- Lecture 23ENG101- English Comprehension- Lecture 23
ENG101- English Comprehension- Lecture 23
 

Similar to CS101- Introduction to Computing- Lecture 44

Refactoring workshop
Refactoring workshop Refactoring workshop
Refactoring workshop
Itzik Saban
 
Overview of Software Engineering Principles - SCPS311.pptx
Overview of Software Engineering Principles - SCPS311.pptxOverview of Software Engineering Principles - SCPS311.pptx
Overview of Software Engineering Principles - SCPS311.pptx
BypassFrp
 
Anti patterns part 2
Anti patterns part 2Anti patterns part 2
Anti patterns part 2
Return on Intelligence
 
Growing as a software craftsperson (part 1) From Pune Software Craftsmanship.
Growing as a software craftsperson (part 1)  From Pune Software Craftsmanship.Growing as a software craftsperson (part 1)  From Pune Software Craftsmanship.
Growing as a software craftsperson (part 1) From Pune Software Craftsmanship.
Dattatray Kale
 
Data Structure and Algorithms
Data Structure and AlgorithmsData Structure and Algorithms
Data Structure and Algorithms
iqbalphy1
 
Kku2011
Kku2011Kku2011
Software Project management
Software Project managementSoftware Project management
Software Project management
sameer farooq
 
Building a custom cms with django
Building a custom cms with djangoBuilding a custom cms with django
Building a custom cms with django
Yann Malet
 
(SPOT205) 5 Lessons for Managing Massive IT Transformation Projects
(SPOT205) 5 Lessons for Managing Massive IT Transformation Projects(SPOT205) 5 Lessons for Managing Massive IT Transformation Projects
(SPOT205) 5 Lessons for Managing Massive IT Transformation Projects
Amazon Web Services
 
CS101- Introduction to Computing- Lecture 45
CS101- Introduction to Computing- Lecture 45CS101- Introduction to Computing- Lecture 45
CS101- Introduction to Computing- Lecture 45
Bilal Ahmed
 
Quality metrics and angular js applications
Quality metrics and angular js applicationsQuality metrics and angular js applications
Quality metrics and angular js applications
nadeembtech
 
Chap 3 - Agile - XP.ppt
Chap 3 - Agile - XP.pptChap 3 - Agile - XP.ppt
Chap 3 - Agile - XP.ppt
Durga Prasad
 
Twelve practices of XP_Se lect5 btech
Twelve practices of XP_Se lect5 btechTwelve practices of XP_Se lect5 btech
Twelve practices of XP_Se lect5 btech
IIITA
 
All about that reactive ui
All about that reactive uiAll about that reactive ui
All about that reactive ui
Paul van Zyl
 
An Introduction To Software Development - Implementation
An Introduction To Software Development - ImplementationAn Introduction To Software Development - Implementation
An Introduction To Software Development - Implementation
Blue Elephant Consulting
 
Polyglot and Poly-paradigm Programming for Better Agility
Polyglot and Poly-paradigm Programming for Better AgilityPolyglot and Poly-paradigm Programming for Better Agility
Polyglot and Poly-paradigm Programming for Better Agility
elliando dias
 
TDD and Related Techniques for Non Developers (2012)
TDD and Related Techniques for Non Developers (2012)TDD and Related Techniques for Non Developers (2012)
TDD and Related Techniques for Non Developers (2012)
Peter Kofler
 
Lecture 7 program development issues (supplementary)
Lecture 7  program development issues (supplementary)Lecture 7  program development issues (supplementary)
Lecture 7 program development issues (supplementary)
alvin567
 
Capability Building for Cyber Defense: Software Walk through and Screening
Capability Building for Cyber Defense: Software Walk through and Screening Capability Building for Cyber Defense: Software Walk through and Screening
Capability Building for Cyber Defense: Software Walk through and Screening
Maven Logix
 
Practices of agile developers
Practices of agile developersPractices of agile developers
Practices of agile developers
DUONG Trong Tan
 

Similar to CS101- Introduction to Computing- Lecture 44 (20)

Refactoring workshop
Refactoring workshop Refactoring workshop
Refactoring workshop
 
Overview of Software Engineering Principles - SCPS311.pptx
Overview of Software Engineering Principles - SCPS311.pptxOverview of Software Engineering Principles - SCPS311.pptx
Overview of Software Engineering Principles - SCPS311.pptx
 
Anti patterns part 2
Anti patterns part 2Anti patterns part 2
Anti patterns part 2
 
Growing as a software craftsperson (part 1) From Pune Software Craftsmanship.
Growing as a software craftsperson (part 1)  From Pune Software Craftsmanship.Growing as a software craftsperson (part 1)  From Pune Software Craftsmanship.
Growing as a software craftsperson (part 1) From Pune Software Craftsmanship.
 
Data Structure and Algorithms
Data Structure and AlgorithmsData Structure and Algorithms
Data Structure and Algorithms
 
Kku2011
Kku2011Kku2011
Kku2011
 
Software Project management
Software Project managementSoftware Project management
Software Project management
 
Building a custom cms with django
Building a custom cms with djangoBuilding a custom cms with django
Building a custom cms with django
 
(SPOT205) 5 Lessons for Managing Massive IT Transformation Projects
(SPOT205) 5 Lessons for Managing Massive IT Transformation Projects(SPOT205) 5 Lessons for Managing Massive IT Transformation Projects
(SPOT205) 5 Lessons for Managing Massive IT Transformation Projects
 
CS101- Introduction to Computing- Lecture 45
CS101- Introduction to Computing- Lecture 45CS101- Introduction to Computing- Lecture 45
CS101- Introduction to Computing- Lecture 45
 
Quality metrics and angular js applications
Quality metrics and angular js applicationsQuality metrics and angular js applications
Quality metrics and angular js applications
 
Chap 3 - Agile - XP.ppt
Chap 3 - Agile - XP.pptChap 3 - Agile - XP.ppt
Chap 3 - Agile - XP.ppt
 
Twelve practices of XP_Se lect5 btech
Twelve practices of XP_Se lect5 btechTwelve practices of XP_Se lect5 btech
Twelve practices of XP_Se lect5 btech
 
All about that reactive ui
All about that reactive uiAll about that reactive ui
All about that reactive ui
 
An Introduction To Software Development - Implementation
An Introduction To Software Development - ImplementationAn Introduction To Software Development - Implementation
An Introduction To Software Development - Implementation
 
Polyglot and Poly-paradigm Programming for Better Agility
Polyglot and Poly-paradigm Programming for Better AgilityPolyglot and Poly-paradigm Programming for Better Agility
Polyglot and Poly-paradigm Programming for Better Agility
 
TDD and Related Techniques for Non Developers (2012)
TDD and Related Techniques for Non Developers (2012)TDD and Related Techniques for Non Developers (2012)
TDD and Related Techniques for Non Developers (2012)
 
Lecture 7 program development issues (supplementary)
Lecture 7  program development issues (supplementary)Lecture 7  program development issues (supplementary)
Lecture 7 program development issues (supplementary)
 
Capability Building for Cyber Defense: Software Walk through and Screening
Capability Building for Cyber Defense: Software Walk through and Screening Capability Building for Cyber Defense: Software Walk through and Screening
Capability Building for Cyber Defense: Software Walk through and Screening
 
Practices of agile developers
Practices of agile developersPractices of agile developers
Practices of agile developers
 

More from Bilal Ahmed

CS201- Introduction to Programming- Lecture 45
CS201- Introduction to Programming- Lecture 45CS201- Introduction to Programming- Lecture 45
CS201- Introduction to Programming- Lecture 45
Bilal Ahmed
 
CS201- Introduction to Programming- Lecture 44
CS201- Introduction to Programming- Lecture 44CS201- Introduction to Programming- Lecture 44
CS201- Introduction to Programming- Lecture 44
Bilal Ahmed
 
CS201- Introduction to Programming- Lecture 43
CS201- Introduction to Programming- Lecture 43CS201- Introduction to Programming- Lecture 43
CS201- Introduction to Programming- Lecture 43
Bilal Ahmed
 
CS201- Introduction to Programming- Lecture 42
CS201- Introduction to Programming- Lecture 42CS201- Introduction to Programming- Lecture 42
CS201- Introduction to Programming- Lecture 42
Bilal Ahmed
 
CS201- Introduction to Programming- Lecture 41
CS201- Introduction to Programming- Lecture 41CS201- Introduction to Programming- Lecture 41
CS201- Introduction to Programming- Lecture 41
Bilal Ahmed
 
CS201- Introduction to Programming- Lecture 40
CS201- Introduction to Programming- Lecture 40CS201- Introduction to Programming- Lecture 40
CS201- Introduction to Programming- Lecture 40
Bilal Ahmed
 
CS201- Introduction to Programming- Lecture 39
CS201- Introduction to Programming- Lecture 39CS201- Introduction to Programming- Lecture 39
CS201- Introduction to Programming- Lecture 39
Bilal Ahmed
 
CS201- Introduction to Programming- Lecture 38
CS201- Introduction to Programming- Lecture 38CS201- Introduction to Programming- Lecture 38
CS201- Introduction to Programming- Lecture 38
Bilal Ahmed
 
CS201- Introduction to Programming- Lecture 37
CS201- Introduction to Programming- Lecture 37CS201- Introduction to Programming- Lecture 37
CS201- Introduction to Programming- Lecture 37
Bilal Ahmed
 
CS201- Introduction to Programming- Lecture 36
CS201- Introduction to Programming- Lecture 36CS201- Introduction to Programming- Lecture 36
CS201- Introduction to Programming- Lecture 36
Bilal Ahmed
 
CS201- Introduction to Programming- Lecture 35
CS201- Introduction to Programming- Lecture 35CS201- Introduction to Programming- Lecture 35
CS201- Introduction to Programming- Lecture 35
Bilal Ahmed
 
CS201- Introduction to Programming- Lecture 32
CS201- Introduction to Programming- Lecture 32CS201- Introduction to Programming- Lecture 32
CS201- Introduction to Programming- Lecture 32
Bilal Ahmed
 
CS201- Introduction to Programming- Lecture 31
CS201- Introduction to Programming- Lecture 31CS201- Introduction to Programming- Lecture 31
CS201- Introduction to Programming- Lecture 31
Bilal Ahmed
 
CS201- Introduction to Programming- Lecture 30
CS201- Introduction to Programming- Lecture 30CS201- Introduction to Programming- Lecture 30
CS201- Introduction to Programming- Lecture 30
Bilal Ahmed
 
CS201- Introduction to Programming- Lecture 29
CS201- Introduction to Programming- Lecture 29CS201- Introduction to Programming- Lecture 29
CS201- Introduction to Programming- Lecture 29
Bilal Ahmed
 
CS201- Introduction to Programming- Lecture 28
CS201- Introduction to Programming- Lecture 28CS201- Introduction to Programming- Lecture 28
CS201- Introduction to Programming- Lecture 28
Bilal Ahmed
 
CS201- Introduction to Programming- Lecture 26
CS201- Introduction to Programming- Lecture 26CS201- Introduction to Programming- Lecture 26
CS201- Introduction to Programming- Lecture 26
Bilal Ahmed
 
CS201- Introduction to Programming- Lecture 25
CS201- Introduction to Programming- Lecture 25CS201- Introduction to Programming- Lecture 25
CS201- Introduction to Programming- Lecture 25
Bilal Ahmed
 
CS201- Introduction to Programming- Lecture 23
CS201- Introduction to Programming- Lecture 23CS201- Introduction to Programming- Lecture 23
CS201- Introduction to Programming- Lecture 23
Bilal Ahmed
 
CS201- Introduction to Programming- Lecture 21
CS201- Introduction to Programming- Lecture 21CS201- Introduction to Programming- Lecture 21
CS201- Introduction to Programming- Lecture 21
Bilal Ahmed
 

More from Bilal Ahmed (20)

CS201- Introduction to Programming- Lecture 45
CS201- Introduction to Programming- Lecture 45CS201- Introduction to Programming- Lecture 45
CS201- Introduction to Programming- Lecture 45
 
CS201- Introduction to Programming- Lecture 44
CS201- Introduction to Programming- Lecture 44CS201- Introduction to Programming- Lecture 44
CS201- Introduction to Programming- Lecture 44
 
CS201- Introduction to Programming- Lecture 43
CS201- Introduction to Programming- Lecture 43CS201- Introduction to Programming- Lecture 43
CS201- Introduction to Programming- Lecture 43
 
CS201- Introduction to Programming- Lecture 42
CS201- Introduction to Programming- Lecture 42CS201- Introduction to Programming- Lecture 42
CS201- Introduction to Programming- Lecture 42
 
CS201- Introduction to Programming- Lecture 41
CS201- Introduction to Programming- Lecture 41CS201- Introduction to Programming- Lecture 41
CS201- Introduction to Programming- Lecture 41
 
CS201- Introduction to Programming- Lecture 40
CS201- Introduction to Programming- Lecture 40CS201- Introduction to Programming- Lecture 40
CS201- Introduction to Programming- Lecture 40
 
CS201- Introduction to Programming- Lecture 39
CS201- Introduction to Programming- Lecture 39CS201- Introduction to Programming- Lecture 39
CS201- Introduction to Programming- Lecture 39
 
CS201- Introduction to Programming- Lecture 38
CS201- Introduction to Programming- Lecture 38CS201- Introduction to Programming- Lecture 38
CS201- Introduction to Programming- Lecture 38
 
CS201- Introduction to Programming- Lecture 37
CS201- Introduction to Programming- Lecture 37CS201- Introduction to Programming- Lecture 37
CS201- Introduction to Programming- Lecture 37
 
CS201- Introduction to Programming- Lecture 36
CS201- Introduction to Programming- Lecture 36CS201- Introduction to Programming- Lecture 36
CS201- Introduction to Programming- Lecture 36
 
CS201- Introduction to Programming- Lecture 35
CS201- Introduction to Programming- Lecture 35CS201- Introduction to Programming- Lecture 35
CS201- Introduction to Programming- Lecture 35
 
CS201- Introduction to Programming- Lecture 32
CS201- Introduction to Programming- Lecture 32CS201- Introduction to Programming- Lecture 32
CS201- Introduction to Programming- Lecture 32
 
CS201- Introduction to Programming- Lecture 31
CS201- Introduction to Programming- Lecture 31CS201- Introduction to Programming- Lecture 31
CS201- Introduction to Programming- Lecture 31
 
CS201- Introduction to Programming- Lecture 30
CS201- Introduction to Programming- Lecture 30CS201- Introduction to Programming- Lecture 30
CS201- Introduction to Programming- Lecture 30
 
CS201- Introduction to Programming- Lecture 29
CS201- Introduction to Programming- Lecture 29CS201- Introduction to Programming- Lecture 29
CS201- Introduction to Programming- Lecture 29
 
CS201- Introduction to Programming- Lecture 28
CS201- Introduction to Programming- Lecture 28CS201- Introduction to Programming- Lecture 28
CS201- Introduction to Programming- Lecture 28
 
CS201- Introduction to Programming- Lecture 26
CS201- Introduction to Programming- Lecture 26CS201- Introduction to Programming- Lecture 26
CS201- Introduction to Programming- Lecture 26
 
CS201- Introduction to Programming- Lecture 25
CS201- Introduction to Programming- Lecture 25CS201- Introduction to Programming- Lecture 25
CS201- Introduction to Programming- Lecture 25
 
CS201- Introduction to Programming- Lecture 23
CS201- Introduction to Programming- Lecture 23CS201- Introduction to Programming- Lecture 23
CS201- Introduction to Programming- Lecture 23
 
CS201- Introduction to Programming- Lecture 21
CS201- Introduction to Programming- Lecture 21CS201- Introduction to Programming- Lecture 21
CS201- Introduction to Programming- Lecture 21
 

Recently uploaded

Leveraging Generative AI to Drive Nonprofit Innovation
Leveraging Generative AI to Drive Nonprofit InnovationLeveraging Generative AI to Drive Nonprofit Innovation
Leveraging Generative AI to Drive Nonprofit Innovation
TechSoup
 
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdfবাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
eBook.com.bd (প্রয়োজনীয় বাংলা বই)
 
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdfANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
Priyankaranawat4
 
Wound healing PPT
Wound healing PPTWound healing PPT
Wound healing PPT
Jyoti Chand
 
BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...
BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...
BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...
Nguyen Thanh Tu Collection
 
IGCSE Biology Chapter 14- Reproduction in Plants.pdf
IGCSE Biology Chapter 14- Reproduction in Plants.pdfIGCSE Biology Chapter 14- Reproduction in Plants.pdf
IGCSE Biology Chapter 14- Reproduction in Plants.pdf
Amin Marwan
 
B. Ed Syllabus for babasaheb ambedkar education university.pdf
B. Ed Syllabus for babasaheb ambedkar education university.pdfB. Ed Syllabus for babasaheb ambedkar education university.pdf
B. Ed Syllabus for babasaheb ambedkar education university.pdf
BoudhayanBhattachari
 
Your Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective UpskillingYour Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective Upskilling
Excellence Foundation for South Sudan
 
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
Nguyen Thanh Tu Collection
 
How to Setup Warehouse & Location in Odoo 17 Inventory
How to Setup Warehouse & Location in Odoo 17 InventoryHow to Setup Warehouse & Location in Odoo 17 Inventory
How to Setup Warehouse & Location in Odoo 17 Inventory
Celine George
 
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
PECB
 
math operations ued in python and all used
math operations ued in python and all usedmath operations ued in python and all used
math operations ued in python and all used
ssuser13ffe4
 
Constructing Your Course Container for Effective Communication
Constructing Your Course Container for Effective CommunicationConstructing Your Course Container for Effective Communication
Constructing Your Course Container for Effective Communication
Chevonnese Chevers Whyte, MBA, B.Sc.
 
How to Make a Field Mandatory in Odoo 17
How to Make a Field Mandatory in Odoo 17How to Make a Field Mandatory in Odoo 17
How to Make a Field Mandatory in Odoo 17
Celine George
 
A Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdfA Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdf
Jean Carlos Nunes Paixão
 
Temple of Asclepius in Thrace. Excavation results
Temple of Asclepius in Thrace. Excavation resultsTemple of Asclepius in Thrace. Excavation results
Temple of Asclepius in Thrace. Excavation results
Krassimira Luka
 
Solutons Maths Escape Room Spatial .pptx
Solutons Maths Escape Room Spatial .pptxSolutons Maths Escape Room Spatial .pptx
Solutons Maths Escape Room Spatial .pptx
spdendr
 
writing about opinions about Australia the movie
writing about opinions about Australia the moviewriting about opinions about Australia the movie
writing about opinions about Australia the movie
Nicholas Montgomery
 
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UPLAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
RAHUL
 
The History of Stoke Newington Street Names
The History of Stoke Newington Street NamesThe History of Stoke Newington Street Names
The History of Stoke Newington Street Names
History of Stoke Newington
 

Recently uploaded (20)

Leveraging Generative AI to Drive Nonprofit Innovation
Leveraging Generative AI to Drive Nonprofit InnovationLeveraging Generative AI to Drive Nonprofit Innovation
Leveraging Generative AI to Drive Nonprofit Innovation
 
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdfবাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
 
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdfANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
 
Wound healing PPT
Wound healing PPTWound healing PPT
Wound healing PPT
 
BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...
BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...
BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...
 
IGCSE Biology Chapter 14- Reproduction in Plants.pdf
IGCSE Biology Chapter 14- Reproduction in Plants.pdfIGCSE Biology Chapter 14- Reproduction in Plants.pdf
IGCSE Biology Chapter 14- Reproduction in Plants.pdf
 
B. Ed Syllabus for babasaheb ambedkar education university.pdf
B. Ed Syllabus for babasaheb ambedkar education university.pdfB. Ed Syllabus for babasaheb ambedkar education university.pdf
B. Ed Syllabus for babasaheb ambedkar education university.pdf
 
Your Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective UpskillingYour Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective Upskilling
 
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
 
How to Setup Warehouse & Location in Odoo 17 Inventory
How to Setup Warehouse & Location in Odoo 17 InventoryHow to Setup Warehouse & Location in Odoo 17 Inventory
How to Setup Warehouse & Location in Odoo 17 Inventory
 
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
 
math operations ued in python and all used
math operations ued in python and all usedmath operations ued in python and all used
math operations ued in python and all used
 
Constructing Your Course Container for Effective Communication
Constructing Your Course Container for Effective CommunicationConstructing Your Course Container for Effective Communication
Constructing Your Course Container for Effective Communication
 
How to Make a Field Mandatory in Odoo 17
How to Make a Field Mandatory in Odoo 17How to Make a Field Mandatory in Odoo 17
How to Make a Field Mandatory in Odoo 17
 
A Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdfA Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdf
 
Temple of Asclepius in Thrace. Excavation results
Temple of Asclepius in Thrace. Excavation resultsTemple of Asclepius in Thrace. Excavation results
Temple of Asclepius in Thrace. Excavation results
 
Solutons Maths Escape Room Spatial .pptx
Solutons Maths Escape Room Spatial .pptxSolutons Maths Escape Room Spatial .pptx
Solutons Maths Escape Room Spatial .pptx
 
writing about opinions about Australia the movie
writing about opinions about Australia the moviewriting about opinions about Australia the movie
writing about opinions about Australia the movie
 
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UPLAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
 
The History of Stoke Newington Street Names
The History of Stoke Newington Street NamesThe History of Stoke Newington Street Names
The History of Stoke Newington Street Names
 

CS101- Introduction to Computing- Lecture 44

  • 1. 1 CS101 Introduction to Computing Lecture 44Programming Methodology (Web Development Lecture 15)
  • 2. 2 During the last lecture we discussed Graphics & Animation • We became able to add and manipulate images and simple animations to a Web page
  • 3. 3 Images in HTML • It is quite straight forward to include gif and jpg images in an html Web page using the <IMG> tag • Format: <IMG src=URL, alt=text height=pixels width=pixels align="bottom|middle|top"> • Plea: Don’t use images just for the sake of it!
  • 4. 4 Images in JavaScript • Images in JavaScript can be manipulated in many ways using the built-in object, Image • Properties: name, border, complete, height, width, hspace, vspace, lowsrc, src • Methods: None • Event handlers: onAbort, onError, onLoad, etc.
  • 5. 5 Image Preloading • The primary use for an Image object is to download an image into the cache before it is actually needed for display • This technique can be used to create smooth animations or to display one of several images based on the requirement
  • 6. 6 The Image Pre-Loading Process 1. An instance of the Image object is created using the new keyword 2. The src property of this instance is set equal to the filename of the image to be pre-loaded 3. That step starts the down-loading of the image into the cache without actually displaying it 4. When a pre-loaded image is required to be displayed, the src property of the displayed image is set to the src property of the pre- fetched image
  • 7. 7 Animated Gifs • We could have saved the 16 gif images of the previous example in a single file in the form of an animated gif, and then used it in a regular <IMG> tag to display a moving image • However, JavaScript provides better control over the sequencing and the gap between the individual images • Example
  • 8. 8 Today’s Goals (Programming Methodology) • To understand effective programming practices that result in the development of correct programs with minimum effort • To become familiar with testing & debugging
  • 9. 9 programmingprogramming methodologymethodology?? The process used by an individual or a team for developing programs
  • 10. 10 programmingprogramming methodologymethodology?? goodgoodA methodology that enables the lowest-cost and on-schedule development of programs that are correct, easy to maintain & enhance
  • 12. 12 readablereadable programprogram?? A program that is easy to read & understand, and therefore, easy to maintain & enhance
  • 13. 13 swapFlag = true ; while ( swapFlag == true ) { swapFlag = false ; for ( k = 0 ; k < ht.length - 1 ; k++ ) { if ( ht[ k ] < ht[ k + 1 ] ) { temp = ht[ k + 1 ] ; ht[ k + 1 ] = ht[ k ] ; ht[ k ] = temp ; swapFlag = true ; } } } How can we make it more readable? What is its most complex aspect? Bubble Sort
  • 14. 14 for ( j = 0 ; j < 100000 ; j++ ) { for ( k = 0 ; k < ht.length - 1 ; k++ ) { if ( ht[ k ] < ht[ k + 1 ] ) { temp = ht[ k + 1 ] ; ht[ k + 1 ] = ht[ k ] ; ht[ k ] = temp ; } } }
  • 15. 15 Readable programs are:Readable programs are: -- moremore readablereadable - efficient- efficient enoughenough
  • 17. 17 Design Guidelines • Break your code down into short and simple functions (e.g. take the 3 swap statements out from the last example and put them into a function of their own) • Do not use global variables
  • 18. 18 Coding Guidelines • Always use semicolons to end statements • Indent blocks of code (2 to 5 spaces) • Identifiers: – Use the camelBack scheme – Make them descriptive but concise – Variables: nouns – Functions: verbs • Comment liberally
  • 19. 19 Comments let the code speak for itself!
  • 20. 20 Guidelines for Developing Short Programs 1. Read, understand the problem 2. Do you have all the required data? No: Get it Else assume it. State it explicitly
  • 21. 21 Example: Problem Statement • Develop a Web page that displays an order taking form • It takes the number of items required for each product, multiplies with the prices, sums them up, adds the GST, and displays the total value of the order
  • 22. 22 Guidelines for Developing Short Programs 1. Read, understand the problem 2. Do you have all the required data? No: Get it Else assume it. State it explicitly 3. Do the design
  • 23. 23
  • 24. 24 Developing Short Programs 1. Read, understand the problem 2. Do you have all the required data? No: Get it Else assume it. State it explicitly 3. Do the design 4. Write test cases
  • 25. 25
  • 26. 26 Developing Short Programs 1. Read, understand the problem 2. Do you have all the required data? No: Get it Else assume it. State it explicitly 3. Do the design 4. Write test cases 5. Write the code on a piece of paper 6. Hand-check it 7. Type it in 8. Run & check it on test cases 9. Errors? fix & redo 9 Done!
  • 27. 27 Design & Code Reviews • Probably the most efficient way of improving the a program • Being humans, at time we see what is supposed to be there instead of what is actually there • Another pair of eyeballs may not have the same problem, especially if they were not involved in building the design or code
  • 28. 28 Two Popular Review Methods 1. Give the problem statement, design, and code (that includes all assumptions) to a peer, and ask him/her to see if things have been done properly 2. Walk a peer or a group of peers through the problem, the design, and the code yourself Which of the two is better?
  • 29. 29 Is it possible to write defect- free programs?
  • 30. 30 Is it even advisable to attempt writing programs that are free of defects?
  • 31. 31 Testing & Debugging • Testing: The tasks performed to determine the existence of defects • Debugging: The tasks performed to detect the exact location of defects • Defects are also called bugs or errors • Let us now look at one of their classifications
  • 32. 32 Types of Errors • Syntax errors • Semantic errors • Run-time errors
  • 33. Syntax Errors • They are caused by the code that somehow violates the rules of the language • Easy to detect and fix errors • The browser stops code interpretation on detecting one of these • Examples: – a = b + * c ; – receiver = reciever + 2 Syntax error?
  • 34. 34 Semantic Errors • Occur when a statement executes and has an effect not intended by the programmer • Hard to detect during normal testing • Often times occur only in unusual & infrequent circumstances • The ‘+’ operator often results in unintended consequences. Remedy: Convert, before use
  • 35. 35 Run-Time Errors • Occur when the program is running and tries to do something that is against the rules • Example: Accessing a non-existent variable, property, method, object, etc (e.g. a method name is misspelled) • Sources of these can be determined by a careful reading of the code, but unfortunately, not always!
  • 38. 38 name = "Bhola ; Syntax Error
  • 40. 40 x = 1.3 ; x.upperCase( ) ; Run-time Error
  • 41. 41 income = document.myForm.salary.value + document.myForm.bonus.value ; Semantic Error
  • 43. 43 if ( today = “holiday” ) mood = “good” ;
  • 44. 44 if ( today == “holiday” ) ; mood = “good” ;
  • 45. 45 if ( today == “holiday” || weather == “OK” mood = “excellent” ;
  • 46. 46 function doThis ( tiger ) { box[ 0 ] = tiger ; x = box[ 0 ] ; return x ;
  • 47. 47 box = new array( 10 ) ;
  • 48. 48 box = new Array( 10 ) ; box( 0 ) = 43 ;
  • 49. 49 Helpful Editors • Using smart editors (e.g. DreamWeaver, nedit) can help in avoiding many types of syntax errors • They can, for example: – Automatically color different parts of statements in different colors, e.g. comments in Gray, strings in Green, HTML tags in Blue – Auto indent – Visually indicate the presence of mismatched parentheses, curly braces or square brackets
  • 50. 50 During Today’s Lecture … • We looked at a few effective programming practices that result in the development of correct programs with minimum effort • We also became familiar with testing & debugging
  • 51. 51 Final Lecture: Review & Wrap-Up • To review a selection from the interesting ideas that we explored over the last 44 lectures