Mid 1 Slide 1
Mid 1 Slide 1
Mid 1 Slide 1
Introduction
Program ?
Drawbacks
binary is hard (for humans) to
work with.
simply too slow and tedious
for most programmers.
Assembly languages
• English-like abbreviations to represent elementary
operations.
• Translator programs called assemblers were
developed to convert assembly-language programs to
machine language at computer speeds.
Example (C = A + B)
load A Drawbacks
add B Programmers still had to use
store C many instructions to accomplish
even the simplest tasks.
High-level Languages
• Translator programs called compilers convert
high-level language programs into machine
language.
• Allow us to write instructions that look
almost like everyday English and contain
commonly used mathematical notations.
(For example: C = A + B)
Advantages
simpler to write & understand
more library support, data
structures
Compiler vs. Interpreter
• Both Compiler and Interpreter are piece of code that
translates the high level language into machine
language.
• Compiler
– scans the entire program first and then translates it into
machine code which will be executed by the computer
processor.
• Interpreter
– translates every statements it into machine code and which
will be executed by the computer processor one by one.
A Survey of Programming Techniques
• Unstructured programming
• Procedural programming
• Modular programming and
• Object-oriented programming
Unstructured Programming
• Small and simple programs consisting only of one
main program
• Disadvantage:
– The main program directly operates on global data.
– Difficult to manage as the program gets sufficiently large.
Procedural Programming
• Combine sequences
of statements into
one single place
(known as
procedure).
• Program can be
viewed as a sequence
of procedure calls.
Procedural Programming
Disadvantage
1. When changes are made to the main procedure (top),
those changes can cascade to the sub procedures of main,
and the sub-sub procedures and so on, where the change
may impact all procedures.
2. Unrestricted access to global data.
Modular Programming
• Procedures of a common
functionality are grouped
together into separate
modules.
• Divided into several
smaller parts which
interact through procedure
calls and which form the
whole program
• Each module can have its
own data.
Modular Programming
• Advantages
– Make your actual program shorter
– Easier to read and understand
– Make it simpler to figure out how the program
operates
– Reduce the likelihood of bugs
Modular Programming
• Drawbacks
– difficult to relate with the real world objects.
– need more memory space and extra rime for
execution because some modules partly repeat the
task performed by other modules.
– Integration of various modules into a single program
may not be easy because different people working
on design of different modules may not have the
same style.
Object
Object