Week10 final

35
Lecture 1 0 Software Programming Microsof t .Ne t Basic C++ Per l C Pytho n Pascal Cobol

Transcript of Week10 final

Lecture 10Software

Programming

Microsoft

.Net Basic

C++P

er

lC Pytho

nP

ascal

Cob

ol

1. Programming: a five step procedure Clarify the programming needs Design the program Code the program Test the program Document and maintain the program

2. 5 generations of programming languages3. Commonly used programming languages

Structural and object oriented Methodologies Compiled and interpreted languages How programs are compiled

4. Object-oriented and Visual programming

Today’s lecture outline

Programming-a five step procedure

1 Specification

Design

Programming

Debugging

Testing

Programming specification

1st step: Program specification

Program solving the problem

Problem

Programmer

A program is used to solve a problem

Programming specification

Computer has to be precisely told what it needs to do; otherwise:

Program design2nd step: Program design

Algorithm:

Set of finite steps that solves a

problem Algorithms are of many types

Algorithms may be classified into:

1. Optimal algorithms(solves the problem to give the ‘best’ result)

2. Non-optimal algorithms(may or may not provide acceptable results)

Program design

Classes of algorithm (non-exhaustive):

1. Deterministic vs. non-

deterministic;

2. Exact vs. approximate algorithms;

3. Optimal vs. non-optimal

algorithms;

Some algorithmic design paradigm:

4. Divide and Conquer algorithms;

5. Probabilistic algorithms;

6. Greedy algorithms; many others.

Program design

Heuristics:

Set of steps that usually solves a problem;

Solution may be non-optimal; Good heuristics provide non-optimal

but acceptable solution for difficult problems;

Used when optimal algorithms are complex/ non-existent.

Program design

Two components of design process:

1)Macro planning: high-level program

logic; (modularization)

2)Micro planning: the detailed

planning;

(how to implement logic)What to do?how to do it?

Hierarchy Chart

Program design

Program’s logical structure:

1. Top-down design

2. Logical hierarchy

3. Modularization

Modules:

1. Manageable size,

2. Defined input/ output

Program design

Program’s design details:

2 ways to show details:

i) Pseudocode: describes logic and processing flow in human-language statements

ii) Flow chart: graphically represents logic flow.

Most projects use both methods

Program design

STARTSTOP

INPUTOUTPUT

CONNECTOR

FLOW LINES

STOP

inputCentcentigrade

calcFahfahrenheit = (1.8*centigrade) +

32

outputFahfahrenheit

STARTConvert Centigrade to Fahrenheit

PSEUDOCODE:

Display “Enter Centigrade: "

Input centigrade

fahrenheit = 1.8 * centigrade + 32

Display “Centigrade to Fahrenheit = "

fahrenheit

Program design

Source Code

Hierarchy chart

Flow chart

Pseudo Code

Machine Code

Program

Designing

Program coding

3rd step: Program coding

1)Select the appropriate programming language

2)Follow the Syntax of the chosen programming language

Program coding paradigms

1)Structured Programming:also called procedural programming because it uses functions or procedures

Benefits: reuse code written as function programs are modular/

structured

2) Object Oriented Programming: (to be covered later)

Common instructions1. Input: from keyboard, file, or some

device

2. Output: to display, file, or some device

3. Maths (logic): addition, multiplication,

etc.

Control Structures4. Sequence: instructions executed in

sequence

5. Selection: conditional execution (if-then-

else)

6. Iteration: some action repeatedly (do

while)

Program coding

Program coding

Source Code

Hierarchy chart

Flow chart

Pseudo Code

Machine Code

Progra

m

Coding

Program testing

4th step: Program testing

1)Perform desk checking

2)Quality assurance

3)Debug the program

4)Run real world data

Program maintenance

5th step: Program documentation/ maintenance

1) Prepare user documentation

2) Prepare operator documentation

3) Write programmer documentation

4) Maintain the program

Five generations of Programming languages

2

1GL: Machine language

1st generation: machine language

•Written in binary

•Different for every CPU

•Used for programming computers in the earliest days of computers.

•Computers only understand this language

2GL: Assembly language

2nd generation: assembly language

LOAD BASEPAYADD OVERPAYSTORE GROSSPAY

• Symbolic representation of machine language.– opcodes– operands– labels

• More readable to human (not computer).

add A, B 1000111000010110

• Easy to translate to machine language.Machine languageAssembly language

Machine language

Assembly language

3GL- High-level language3rd generation: high-level language

•Supports structured and object-

oriented programming (OOP)

•Abstracts the hardware

implementation from the programmer

•Code is reusable and portable

•May be compiled/ or interpreted

Program execution (C example)

Compilers vs. Interpreters

4GL-Very high-level languages4th

generation: very high-level languageNon procedural high-level

specification language.

4GL open up the development environment to a wider population

Examples:

Database query language: SQL;

General use: PowerBuilder;

5GL- Natural languages5th generation: natural language

Algorithms do not have to be

specified

Aims to make the programmer

redundant

May not be created yet

Will create software automatically

Commonly usedProgramming languages

3

Common Program Languages

Microsoft

.Net Basic

C++P

er

l

C Python

Pascal

Cob

ol

Objected-Oriented & Visual Programming4

Object Oriented Programming

Also called OOP Intuitive method of programming Code reuse

Code used in many projects Speeds up program development Simplifies program development

Enhances structured programming

Object Oriented Programming

Develops objects

All real world items are objects

Contains data about the item

Contains functionality

Object encapsulates both into one package

Visual Programming

Programming is done using a graphical interface;

No actual coding is done;

Code is generated through specification of functionality using menus and graphical manipulation of program elements;

Intended to be user friendly.

1. Programming: a five step procedure Clarify the programming needs Design the program Code the program Test the program Document and maintain the program

2. Five generations of programming languages3. Commonly used programming languages4. Object-oriented and Visual programming

Today’s lecture summary

???Questions/

Confusions?

Credits/ Acknowledgement can be found

at the course website:

http://tinyurl.com/5hb8pp