Programming Methodology - Introduction to Computing - Lecture Slides, Slides of Introduction to Computing

Programming Methodology, Effective programming practices, Testing, Debugging, Guidelines, Coding Guidelines, Guidelines for Developing Short Programs, Design and Code Reviews and some other key points are also part of this lecture.

Typology: Slides

2011/2012

Uploaded on 11/03/2012

banamala
banamala 🇮🇳

4.4

(19)

114 documents

1 / 50

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
CS101 Introduction to Computing
Lecture 44
Programming Methodology
(Web Development Lecture 15)
1
Docsity.com
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26
pf27
pf28
pf29
pf2a
pf2b
pf2c
pf2d
pf2e
pf2f
pf30
pf31
pf32

Partial preview of the text

Download Programming Methodology - Introduction to Computing - Lecture Slides and more Slides Introduction to Computing in PDF only on Docsity!

CS101 Introduction to Computing

Lecture 44

Programming Methodology

(Web Development Lecture 15)

During the last lecture we discussed Graphics & Animation

  • We became able to add and manipulate images and simple animations to a Web page

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.

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

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 tag to display a moving image
  • However, JavaScript provides better control over the sequencing and the gap between the individual images
  • Example

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

programming

methodology?

10

good A methodology that enables the lowest-cost and on- schedule development of programs that are correct, easy to maintain & enhance

correct

program?

11

A program with correct syntax & semantics

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 ;

} Docsity.com

guidelines

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

Comments let the

code speak for

itself!

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