Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 59

INTRODUCTION TO PROGRAMMING

Chapter 2 : Introduction to
Programming

© Nurkhairizan’07
INTRODUCTION TO PROGRAMMING

Objectives
By the end of the lesson, student should
be able to
1. Define what is Programming
Language
2. Describe the evolution of
Programming Language
3. List the advantages of OOP
4. Describe what is OOP
INTRODUCTION TO PROGRAMMING

Content

• What is Programming
• What is Programming Language
• A Program (Software)
• Evolution of Computer Program
INTRODUCTION TO PROGRAMMING

Content

• What is Programming
• What is Programming Language
• A Program (Software)
• Evolution of Computer Program
INTRODUCTION TO PROGRAMMING

What is programming
• Computer programming (often
shortened to programming or coding)
is the process of writing, testing,
debugging/troubleshooting, and
maintaining the source code of
computer programs.
INTRODUCTION TO PROGRAMMING

Content

• What is Programming
• What is Programming
Language
• A Program (Software)
• Evolution of Computer Program
INTRODUCTION TO PROGRAMMING

What is Programming Language?


• A vocabulary and set of grammatical rules for
instructing a computer to perform specific tasks.
• The term programming language usually refers
to high-level languages, such as BASIC, C, C+
+, COBOL, FORTRAN, Ada, and Pascal.
• Each language has a unique set of keywords
(words that it understands) and a special syntax
for organizing program instructions.
INTRODUCTION TO PROGRAMMING

Content

• What is Programming
• What is Programming Language
• A Program (Software)
• Evolution of Computer Program
INTRODUCTION TO PROGRAMMING

A Program (Software)
• Program is a set of instruction that tells
computer what to do.
• The instructions is written in
Programming Language.
INTRODUCTION TO PROGRAMMING

A Program (Software)

Software is
– applications
– operating systems and environments
– utilities: compilers, editors...
• all created by human effort
as collections of related programs
using programming languages
INTRODUCTION TO PROGRAMMING

Content

• What is Programming
• What is Programming Language
• A Program (Software)
• Evolution of Computer
Program
INTRODUCTION TO PROGRAMMING

Evolution of Computer
Programming
• The Generations of programming
languages
• Language generations 1,2,3
• High level languages: the evolution of
types of language
INTRODUCTION TO PROGRAMMING

Evolution of Computer
Programming
• The Generations of
programming languages
• Language generations 1,2,3
• High level languages: the evolution of
types of language
INTRODUCTION TO PROGRAMMING

The Generations of programming


languages
Generations of languages relate to degree of
problem- or human- orientation vs machine
orientation.
These generations are not the same as
the generations of computer architecture.

[from Brookshear Figure 5.1]


INTRODUCTION TO PROGRAMMING

Evolution of Computer
Programming
• The Generations of programming
languages
• Language generations 1,2,3
• High level languages: the evolution of
types of language
INTRODUCTION TO PROGRAMMING

Language generations 1,2,3


1. machine languages
2. assembly languages
3. high level languages
– FORTRAN, COBOL, ALGOL, LISP

• the biggest differences are in


– execution control structures,
(program control, flow control)
– data control
– modularity
INTRODUCTION TO PROGRAMMING

Generations of
programming languages -& computers
programming languages computer architectures
1. machine lang 1. valves 1945
1945
2. assembly lang 1951
3. high level lang 1954 2. transistors 1959
60s 3. Integrated 1964
Circuits
4. 4GLs 70s
4. PCs many high
1981
5. AI based 80s level
6. network-aware 90s languages of
different
types
INTRODUCTION TO PROGRAMMING

Content

• What is Programming
• What is Programming Language
• A Program (Software)
• Evolution of Computer
Program
INTRODUCTION TO PROGRAMMING

High level languages: the


evolution of types of language

Simula-67 Eiffel

[Brookshear Figure 5.2] plus S67 & Eiffel


TCP2103 : INTRODUCTION TO PROGRAMMING

Object Oriented Programming


INTRODUCTION TO PROGRAMMING

Content

• Programming Approach
• What is OOP?
• What is Object?
• Advantage of OOP
INTRODUCTION TO PROGRAMMING

Content

• Programming Approach
• What is OOP?
• What is Object?
• Advantage of OOP
INTRODUCTION TO PROGRAMMING

Programming Approach
INTRODUCTION TO PROGRAMMING

Content

• Programming Approach
• What is OOP?
• What is Object?
• Advantage of OOP
INTRODUCTION TO PROGRAMMING

What is OOP
• Object oriented programming (OOP)
models the real world in terms of
object. A bicycle
• Object examples:
A tiger
A circle

A person
INTRODUCTION TO PROGRAMMING

Object Oriented Programming


INTRODUCTION TO PROGRAMMING

Content

• Programming Approach
• What is OOP?
• What is Object?
• Advantage of OOP
INTRODUCTION TO PROGRAMMING

What is Object?
Objects are key to understanding
object-oriented technology.
Real-world objects share two
characteristics
state
Behavior
Identifying the state and behavior for
real-world objects is a great way to
begin thinking in terms of object-
oriented programming.
INTRODUCTION TO PROGRAMMING

Definition

An Object represents an
entity in the real world that
can be distinctly identified
INTRODUCTION TO PROGRAMMING

Object state & Behavior

Object : A cat

State : name, color, breed, hungry

Behavior : barking, fetching, wagging tail

Object : A bicycle

State : current gear, current pedal cadence, current speed


Behavior : changing gear, changing pedal cadence, applying brakes
INTRODUCTION TO PROGRAMMING

Software Object
Software objects are conceptually similar to
real-world objects:
stores its state in data fields (properties)
exposes its behavior through methods
(functions)

Method is a mechanism for object-to-


object communication
INTRODUCTION TO PROGRAMMING

Content

• Programming Approach
• What is OOP?
• What is Object?
• Advantage of OOP
INTRODUCTION TO PROGRAMMING

Advantages of OOP
• Flexibility
– flexible interactions
• Modularity
– The source code for an object can be written
and maintained independently of the source
code for other objects.
• Clarity
– More understandable, better organized and
easier to maintain than procedural
programming
• Reusability
– Classes provide the benefit of reusability
TCP2103 : INTRODUCTION TO PROGRAMMING

The End

© Nurkhairizan’07
INTRODUCTION TO PROGRAMMING

QUIZ
• What is Programming Language?
• Give 3 example of High-level Programming
Language.
• What is Object. Give 2 example of object and
list all possible state (properties) and
behavior (method) for the object
• List 4 advantages of Object Oriented
Programming.
INTRODUCTION TO PROGRAMMING

Structured Programming
INTRODUCTION TO PROGRAMMING

Content

• Programming Approach
• Advantages of Structured
Programming
• Method of solving problem using
structured programming
INTRODUCTION TO PROGRAMMING

Content

• Programming Approach
• Advantages of Structured
Programming
• Method of solving problem using
structured programming
INTRODUCTION TO PROGRAMMING

Programming Approach
INTRODUCTION TO PROGRAMMING

Content

• Programming Approach
• Advantages of Structured
Programming
• Method of solving problem using
structured programming
INTRODUCTION TO PROGRAMMING

What is Structured
Programming(SP)?
• In the world of computer programming,
structured programming is a logical
construct that allows for the efficient
operation of a program. With this in
mind, many programmers understand
structured programming as being one of
the disciplines that make up the overall
process of procedural programming.
INTRODUCTION TO PROGRAMMING

Why structured programming?


• Advantages of structured programming
– Standard method for solving a problem
– “Go-to-less”
– Easier to test and debug than straight-line or
modular programs
• Structured walkthroughs
– A single program can be written by more than one
programmer
– Programs can share routines
– Help minimize thrashing
INTRODUCTION TO PROGRAMMING

Content

• Programming Approach
• Advantages of Structured
Programming
• Method of solving problem using
structured programming
INTRODUCTION TO PROGRAMMING

What Are the Rules for Writing a


Structured Program?
3 basic structures
• Sequence
• Decision (selection)
• Repetition (looping or iteration)
INTRODUCTION TO PROGRAMMING

Sequence Structure
Write a
•Can contain any symbol line

except for the decision symbol. Move


•Steps are executed in Score to
High-Score
sequence with no instruction
Do
changing the order Low-Score

Do
Average
INTRODUCTION TO PROGRAMMING

Decision Structures

If…Then…Else
If…Then

Case
INTRODUCTION TO PROGRAMMING

If…Then

Is
Add 1 to
Code =
1? Yes Code1-Count
No
INTRODUCTION TO PROGRAMMING

If…Then…Else
Is
Gender =
No "F"? Yes

Do Male Do Female

Do Benefit-
Analysis
INTRODUCTION TO PROGRAMMING

Case

Value = ?
=0 >0
<0

Move Move Move


spaces to "Negative" to "Positive" to
Sign Sign Sign
INTRODUCTION TO PROGRAMMING

Repetition (Looping or Iteration)


Structures
• Top-test loop

Bottom-test
loop
INTRODUCTION TO PROGRAMMING

How Many Times is Each of the Following


Loops Executed?

Done = ? D o P ro ce s s
"Yes"
"No"
Done = ?
Do Process "Y e s "
"N o "

Top test Bottom test


INTRODUCTION TO PROGRAMMING

Is This a Top-Test or a Bottom-Test Loop?


INTRODUCTION TO PROGRAMMING

It is neither a top-
test nor bottom-test
loop.

The loop is
invalid!!!!!!
In structured programming the
decision to leave the loop must be
the first instruction or the last
instruction in the loop
INTRODUCTION TO PROGRAMMING

Structured programming
produced significant
improvements in software
quality and development
time…
INTRODUCTION TO PROGRAMMING

What Are the Rules for Writing a


Structured Program?

Only one entrance into and


one exit out of a structure
INTRODUCTION TO PROGRAMMING

Entrance into structure

Exit 1 from Exit 2 from


structure structure
INTRODUCTION TO PROGRAMMING

Entrance 1 Entrance 2
into structure into structure

Exit from structure


TCP2103 : INTRODUCTION TO PROGRAMMING

The End

© Nurkhairizan’07
INTRODUCTION TO PROGRAMMING

EXERCISE
• What is Programming Language?
• Give 3 example of High-level Programming
Language.

You might also like