ARE - 510 - 6 - Programming and Languages

Download as pdf or txt
Download as pdf or txt
You are on page 1of 38

ARE 510

Dpt of Architectural Engineering


College of Environmental Design
KFUPM

D. Ouis
1st semester 2015
Programs and Programming
What exactly is programming?
Many people think of it as simply typing words into a
computer.

It is partly, but mainly it is a problem-solving procedure.

What Is a Program?
A program is a list of instructions for the computer to follow
to accomplish the task of processing data into information.
Programming

It is a process that leads from an original formulation of a


computing problem to executable computer programs.
It involves: analysis, developing understanding,
generating algorithms, verification of requirements of
algorithms, and implementation (coding) of algorithms in a
target programming language.
It may even include: testing, debugging, and maintaining
the source code (collection of computer instructions), which
may be considered as part of the software development
process.
Programming

Programming, (or software


development) is a
six-step procedure:

1. Program specification:
Determine the program‟s
objectives, outputs, inputs,
and processing requirements. are determined.
Programming

2. Program design: A solution is created


using programming techniques such as
top-down program design, pseudocode,
flowcharts, and logic structures.

3. Program code: The program is


written, or coded, using a programming
language.

4. Program test: The program is tested


or debugged by looking for syntax and logic errors.
Programming

5. Program documentation: Documentation is an ongoing


process throughout the programming
process. This phase focuses on
formalizing the written description and
processes used in the program.

6. Program maintenance: Completed


programs are periodically reviewed to
evaluate their accuracy, efficiency,
standardization, and ease of use.
Changes are made to the program‟s code as needed.
Step 1: Program Specification

Also called program definition or program analysis.

5 items:
(1) the program‟s objectives, (2) the desired output, (3) the
input data required, (4) the processing requirements, and (5)
the documentation.
Step 1: Program Specification

(1) Program‟s objectives: what is the problem to be solved?


(2) Desired output: what to get from your PC (picture of
output).
(3) The input data required: the necessary information
needed by the PC.
(4) The processing requirements: the kind of operations.
(5) The documentation: record all the above for later use.
Step 2: Program Design
(1) First determine the outputs and
inputs for the program. Then use
top-down steps: program
modules, each being made
up of logically related program statements

(2) Pseudocode: outline of the logic,


or a kind of summary of the
program to be written.
Step 2: Program Design

(3) Flowcharts: graphical presentation


of the sequence of steps needed to solve
a programming problem.

(4) Logic Structures


How do you link the various parts of the flowchart?
Combination of 3 logic structures:
Concatenation: one program statement follows another.
Selection: decision must be made; IF-THEN-ELSE.
Repetition, or loop: repeat; do-untill, do while.
Step 2: Program Design
Elements of a Program

All programming languages have certain features in


common. For example:

 Variables
 Commands/Syntax (the way commands are
structured)
 Loops
 Decisions
 Functions

Each programming language has a different set of rules


about these features.
Step 2: Program Design
Elements of a Program

ACTIVITY

Create a set of instructions that


will tell us:

How to eat a banana

Make your instructions as detailed


as possible, so that even
someone who has never eaten a
banana before can understand
them.
Step 2: Program Design
Elements of a Program

1. Using your hand, get a yellow crescent-shaped fruit


called a “banana”
2. Peel the outer skin off the banana (by breaking off
the outer stem and peeling back the yellow peel)
3. Eat the banana
1. Put a small section of banana in your mouth
2. Bite down on the banana
3. Chew the banana by opening and closing your mouth
4. Once the banana has been chewed, swallow the banana
5. Repeat until banana is finished
4. Throw out the used banana peel
Step 2: Program Design
Elements of a Program

A procedure that outlines:


what actions you want the computer to perform
and the order in which they happen is called an
ALGORITHM.

An ALGORITHM is basically an outline for how your


computer program will work.
Step 2: Program Design
Elements of a Program

• The ORDER in which actions are performed is also very


important.
• Consider the following 2 algorithms that tell Mr. John how
to get ready in the morning.

Let‟s call them the “Rise-and-Shine Algorithms”


Step 2: Program Design
Elements of a Program

RISE AND SHINE 1 RISE AND SHINE 2


• Get out of bed • Get out of bed
• Take off pyjamas • Take off pyjamas
• Take a shower • Get dressed
• Get dressed • Take a shower
• Eat breakfast • Eat breakfast
• Drive to school • Drive to school
RESULT RESULT
Mr. John arrives in a great Mr. John arrives in not too
mood ready to teach  great a mood since he‟s
soaking wet 
Step 3: Program Code

Writing the program is called coding. It instructs the


computer what to do, i.e. a series of instructions to a
computer to accomplish a task.
Instructions must be written in a way the computer can
understand.
Good way for efficiency: write s.c. structured programs.
Coding
Is accomplished using the appropriate computer language.
E.g. A content-markup language uses symbols, words, and
phrases that instruct a computer how to structure information
for display or processing. Ex: HTML for making web pages.
Step 3: Program Code
A programming language uses a collection of symbols,
words, and phrases that instruct a computer to perform
specific operations.

I know Algol, Basic, Fortran, ….


…and the name of 10 other programming languages.
Step 3: Program Code

TERMINAL : the beginning or ending of a


program.
INPUT/OUTPUT: the user is asked for information
(INPUT) or where to display a result (OUTPUT).

PROCESSING: mathematical operations.

CALL: shows any other pieces of the program


that are called upon (functions, subroutines).

DECISION: any action where the computer is


making a decision (IF-THEN-ELSE)
Step 3: Program Code
Algorithm: example of Euclid's
algorithm for calculating the
greatest common divisor (g.c.d.)
of two numbers A and B:
A = 30 = 2 ∙ 3 ∙ 5
B = 72 = 23 ∙ 32

g.c.d.
(30, 72)
=
2∙3=6
Here are some examples of an instruction to print the
word HI:

o Logo PR [HI]
o JavaScript alert(“HI”);
o FORTRAN PRINT “HI”
o BASIC PRINT “HI”
o COBOL DISPLAY „HI‟.
o C++ printf(“HI”);
o Pascal WRITELN(„HI‟);
o Assembly XPRNT MESSAGE1
Language MESSAGE1 DC „HI‟
Set of commands that a computer has been “taught” to
understand.

Languages that look like “machine code” (e.g., 82A8: jsr


r5,@#82AE 82AC: sob r0,8296) are used for:
Writing games
Writing application programs (like Excel)

Other languages look like English (“high level,” e.g., PRINT


“HELLO”)
Logo
JavaScript
And many more
Step 3: Program Code
How does programming look like?

Example of a code
written in 2 different
versions of FORTRAN
Some programming languages (like Java or C++)
require the code to be compiled (translated to binary)
before it can be started.

Others (like JavaScript) are interpreted, meaning that


each command is translated separately when the
program is started.
Step 4: Program Test

Debugging refers to the process of testing and then


eliminating errors (“getting the bugs out”).

Programming errors are of two types: syntax errors and logic


errors.
Syntax error: violation of the rules of the
programming language, e.g. punctuation.
Logic error: occurs when use of an incorrect
calculation or forgetting of a programming procedure.
Step 4: Program Test
Testing Process:
• Desk checking: or code review: proofreading a printout
of the program.
• Manually testing with sample data: with a calculator
follow all program statements and perform calculation.
• Attempt at translation: The program is run through a
computer, using a translator program (compiler).
• Testing sample data on the computer: After correction
of syntax errors, the program is tested for logic errors.
• Testing by a select group of potential users: Potential
users try out the program and provide feedback.
Step 5: Program Documentation
It consists of written descriptions and procedures about a
program and how to use it. It is carried on throughout all the
programming steps.

• Users: Users need to know how to use the software.

• Operators: If the program sends error messages,


operators need to know what to do about them.

• Programmers: for updating and modifying program:


maintenance.
Step 6: Program Maintenance

The final step! Program maintenance stands for around


75% of the total lifetime cost for an application program.

Operations
Operations activities concern locating and correcting
operational errors, making programs easier to use.

Changing Needs
Programs must change following needs. E.g. new tax laws,
new maps, and new company policies.
CASE and OOP

Efficiency and productivity are particularly important for


software development. Two resources for helping in that:
CASE tools and object-oriented software development.

Computer-Aided Software Engineering (CASE) tools:


Inspired by CAD for designing hardware, CASE tools are
used to develop software that is high-quality, defect-free,
and maintainable.

Object-Oriented Software Development


OOProgramming is a process by which a program is
organized into objects. It is like building a car from
prefabricated parts.
Generations of Programming Languages

Levels or generations of programming languages, from


“low” to “high.”
Lower level when they are closer to the language the
computer itself uses, i.e using 0s and 1s.
Higher level when they are closer to the language
humans use, i.e. more like English.
Generations of Programming Languages

Machine Languages: The First Generation


Two-state system, on-off, composed of 0s and 1s: coding
schemes allowing to represent letters, numbers and
symbols, ex ASCII, for representing texts in computers.
Generations of Programming Languages
Assembly Languages: The Second Generation
Before a computer can process a program, the program
must be converted or translated into machine language.
Assembly languages use abbreviations or mnemonics
that are automatically converted (by an assembler) to the
appropriate sequence of 1s and 0s.
Compared to machine languages, assembly is much easier
to understand by humans.

A very strong correspondence between the language and


the architecture's machine code instructions.
Each assembly language is specific to a particular
computer architecture, as opposite to high level languages.
Generations of Programming Languages

High-Level Procedural Languages: The Third Generation


More English-like programming languages are called “high-
level” languages.
Still some training is required to use these languages,
particularly for procedural languages.
(procedure = routine, method or function)
3GLs, are designed to express the logic - the procedures -
that can solve general problems.

E.g. C++
Generations of Programming Languages

High-Level Procedural Languages: The Third Generation


• A compiler: converts the programmer‟s procedural
language program (source code) into a machine language
code (object code). Ex: FORTRAN.

• An interpreter: converts the procedural language one


statement at a time into machine code just before it is to be
executed. No object code is saved. Ex: BASIC.
Generations of Programming Languages

Task-Oriented Languages: The Fourth Generation


4GLs: very high level language, require little training in
programming.
4GLs are nonprocedural and focus on specifying the specific
tasks the program is to accomplish.
Many 4GLs are part of a DBMS.

• (Structured) Query languages: popular among non-


programmers to search and generate reports from a DB.
• Application generators: or a program coder is a program
that provides modules of prewritten code. Saves time.
Generations of Programming Languages

Problem and Constraint Languages: The Fifth Generation


A (5GL) incorporates the concepts of Artificial Intelligence
i.e. allow a person to define a problem and some constraints,
and then request a solution from the system.
Moreover, a 5GL would enable a computer to learn and to
apply new information as people do: a more directly
communication with a computer.
Generations of Programming Languages

Summary of the evolution of Programming Languages

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy