Chapter 1- Introduction to
Programming
Ntiamoah Nkansah B.SC (Hons)Information
Technology
Lesson Objectives
What is a computer Programming Language?
Generations of computer Programming
Languages
Evaluating Computer Programming
Languages
Introduction to structured Programming
language
An introduction to Object Oriented
Programming
What is a Computer Programming
Language?
Language is the basis of communication. Without a
language there will be no effective communication (sound,
writing or gestures)
There is not one absolute definition of what a computer
programming language is
Programming languages allows computers and humans to
communicate
Computers understand logic expressed mathematically
through what is known as machine code which is in 0’s
and 1’s and human beings understand natural language
Programming languages allows us to write in human
understanding form and then the language is translated
into a form that the computer can understand
What is a Computer Programming
Language?
Let us discuss this definitions:
A computer programming language has been defined as a
tool to help the programmer
A programming language is a way of writing that can be
read by both human beings and machines
A sequence of instructions for a machine to carry out
A way for human beings to communicate with a
machine which is unable to understand natural
language
It offers a way of writing algorithms that can be
understood by both humans and machines.
A computer program offers a human standard way of
expressing algorithms to solve a particular program.
What is a Computer Programming
Language?
In your own definition of what a computer
programming language is?
What is a Computer Programming
Language?
My worked on Definition
A programming language is a tool which offers a means
of writing logical set of instructions (algorithms) that
can be understood by both human beings and machines
Examples of Computer Programming Languages
C, Pascal
Fortran, Cobol
Java, Visual Basic
C#, Prolog,
SQL, Action Script,
etc
What is a Computer Programming
Language?
Algorithm
A systematic procedure that produces –in a
finite number of steps – the answer to a
question or a solution to a problem
Any computing problem can be solved by
executing a series of actions in a specific order.
A procedure for solving a problem in terms of
The actions to be executed and
The order in which the actions are to be executed is
called an algorithm.
What is a Computer Programming
Language?
Example:
Rise and shine Algorithm
(1) Get out of bed (2) take off pajamas
(3) take a shower,
(4) get dressed (5) eat breakfast, (6)
carpool to school
Change sequence of tasks
(1) Get out of bed, (2) take off pajamas,
(3) get dressed,
(4) take a shower,
(5) eat breakfast, (6) carpool to school
Generations of Computer Programming
Languages
There are five (5) generations of computer
programming languages (PL)
First generation PL
Second generation PL
Third generation PL
Fourth generation PL
Fifth generation PL
Every computer generation has it short falls.
New generations of computer languages
addresses this short falls and add more
features and capabilities
Generations of Computer Programming
Languages
First Generation Language
They were machine languages.
Instructions and addresses were numerical.
They were machine dependent
Advantages
The code a user writes can run very fast and efficiently, since it is
directly executed by the CPU.
Disadvantages
Computers were tedious or tiresome to program (learn set of
numeric digits and how to combine then to create instructions.
It was prone to errors
Only computer scientist and professional s were programming
the computer
It was platform dependent
Generations of Computer Programming
Languages
Second Generation languages
Programming languages were still machine
dependent.
Instructions and addresses where symbolic.
A translator called the assembler was used to
translate symbols to machine form.
Examples of 2GL are IBM BAL, and VAX
Macro, etc
Generations of Computer Programming
Languages
Advantages
Refer to disadvantages in the previous
generation
Disadvantages
Programmer require many instructions to
accomplish a simple task
It was still platform dependent
Generations of Computer Programming
Languages
Third Generation Languages
Allow the programmer to concentrate on the
problem instead of the machine they were writing
for.
They are called high level programming languages.
Translator were the compilers and interpreters but
not the assembler.
This is the era of structured programming and
Database management systems and Object
Oriented programming.
Examples FORTRAN, COBOL, Pascal, C, BASIC, C+
+, java, C#, etc
Generations of Computer Programming
Languages
Advantages
Few instructions could accomplish a huge task
Issues of platform dependency was resolved
Disadvantages
It is slow to translate depending on users specs
A lot of brain-intensive work is involved
Generations of Computer Programming
Languages
Forth Generation Languages
They are known as non-procedural languages.
They concentrate on what you want to do rather than
how you want to do it.
Examples include report generators, form generators,
CASE tools, Data Management tools (SAS, SPSS, Stata),
SQL, Postscript, etc
Advantages
Increase in productivity (more achieved in a shortest
possible time)
Disadvantages
It turns to resource intensive and turns slow down
systems
Generations of Computer Programming
Languages
fifth Generation Computers
Are normally concerned with Artificial Intelligence, fuzzy
logic and neural networks.
This language generation allows computers to think for
themselves like human beings by drawing inference using
programmed information in large database
The databases programmed in a specialized area of study
shows a significant expertise greater than humans
Improvements in the fourth generation languages now
carried features where users did not need any
programming knowledge. Little or no coding and computer
aided design with graphics provides an easy to use product
that can generate new applications
Example is prolog
Debate
Intelligence has been defined as the ability to
understand and think about things and to
gain and use knowledge
Since 5th generation programming languages
have empowered computers to thinks and
behave like human beings and they can think
faster, seems to have all answers to human
problems, are more reliable and billion times
faster than humans, can we conclude that
Computers are more intelligent than humans?
Natural Intelligence vs. Artificial
intelligence
Learning
Humans can acquire knowledge through experimenting
Computers can acquire knowledge through direct gathering of
information (from books, web-sites, conversation
Information retrieval from the internal memory ability
Retrieval speed: machines are more faster than computers
Retrieval accuracy: machines
Ability to achieve goals through decision making
Humans can infer and make decisions better than computers
Hardware power
Hardware processing power; computer can process billion times faster
than machines
Hardware memory storage; computers can store more data than humans
Information retrieval speed; computers can retrieve 1000 times faster
than humans
Ways to evaluate a computer
programming language
Choice of programming language will depend to a
large extent on:
How vest you are with the programming language
The environment and standards of the programmer’s
organization
Programmers should choose languages on the basis
of task or goals not by only by familiarity
Examples
If I am suppose to handle structured task, I would go
for a C language other than Java or C#
If I want to create a business application, I may choose
COBOL instead of another programming language
Ways to evaluate a computer
programming language
Considerations :
Is it easy to write the program using that language of choice? It
make the process easier and faster
How reliable is the language. A program that is not robust can
cause errors.
What is the cost involved in developing and updating a program
deployed using a particular language.
How complicated is the syntax for the language? Is the syntax
clear, logical and sensible enough?
Others:
Suitability
Integration
Standards
Programmers’ availability
Portability
Development Speed
Definitions
What is a syntax
The rules defining the prescribed sequence of
symbolic instructions in a language.
What is Parsing
The process of deciding whether a string of
input symbols is a sentence of a given language
and if so determining the syntactical structure
of the string as defined by the grammar for the
language.
Approaches to Computer Programming
Design
Structured Programming Design
Object Oriented Programming Design
Aspect Oriented Programming Design
Service Oriented Programming Design
Structured Programming Design
Structured Programming enforces a logical
structure of a program being written to make it
more efficient and easier to understand, test and
modify
It deals with three (3) structures which are:
Sequence
Selection
Iteration
These structures can be combined in two (2) ways:
Stacking (combination)
Nesting (substitution)
Structured Programming Design
Structured programming also pays attention to
design and testing with emphasis on top-down
approach (Stepwise progression).
The top down approach uses modularity as a
means of ensuring that the program is both legible
and manageable, and also that these modules can
be tested as they are developed
Structured Programming controls three basic
functions of a program namely:
Initialization
Processing
Closing down the program
Structured Programming Design
Program design tools to be used:
Diagrams (DSD’s, PSD’s, Flowcharts)
Pseudo codes
Popular programming languages that support
structured programming
C, Pascal, COBOL, FORTRAN, C++, JAVA, ETC
Object Oriented Programming Design
Principles
The concept of OOP is of the view that
applications can be built by observing object
that work together as opposed to the concept
of structures that forms the basis of
structured programming.
OOP allows objects to be re-used
(inheritance) or be extended (polymorphism)
which help reduce development time
Object Oriented Programming Design
Principles
Classes and Objects
An object can be:
Any physical thing in the real world
a representation of reality
a tangible or visible thing,
a thing to which action or thought can be directed
to
Objects have states (attributes) and behavior
(methods).
An object’s state describes it. An object’s
behavior is the things that it knows how to do
Object Oriented Programming Design
Principles
Examples
Car
States
Engine type, make, color, etc
Behavior
Accelerate, brake, change gear, etc
Dog
States
Name, breed, color
Behaviors
Snoring, barking, chasing
Human being
Attributes
Height, age, height, nationality
Behavior
Eating, sleeping, drinking, playing, etc
Object Oriented Programming Design
Principles
An object is an instance of a class.
A Class is used as templates to create other
objects.
Example
A persons class can be used to create or
instantiate other persons.
Note that a person’s classes can be extended to
create a population.
Classes also have attributes and operations or
behavior
Object Oriented Programming Design
Principles
Classification
Classification looks at the shared attributes
and behavior to create or describe classes of
objects
Example, you can say that lizards, crocodiles,
chameleons may belong to a class known as
reptiles
All reptiles shares attributes such as size and
color and behavior such as laying of eggs
Object Oriented Programming Design
Principles
Types of classes
The abstract class
The concrete class
An abstract class may have one or more
subclasses but never an instance. A reptile is
an example of an abstract class
A concrete class however is a class than can
have one or more subclasses and / or
instances. Lizards and crocodiles are
examples of concrete classes
Object Oriented Programming Design
Principles
Encapsulation (information hiding) and abstraction
Encapsulation is also referred to as black box technology.
With encapsulation, objects bundles together its attributes
and its operations so that they are inseparable, so that it is
only the object that knows about it and can act on it.
The advantage with encapsulation is that, it reduces the
potential for errors.
Although, objects hide its operations from the outside
world, it does offer a means of communication with the
outside world.
This means of communication with the outside world is
known as interface.
Object Oriented Programming Design
Principles
Abstraction
The advantage with abstraction is that, it enables the developer to
re-use a class and filter out operations and attributes that are
superfluous to needs
Messages and Operations
When an object receives a message from another object, it activates
a method or operation.
For example, a remote control sends a message to a television set to
perform an operation such as change channel.
The process of passing a message from a message sender to a
message receiver is termed message passing.
Massage may also contain arguments or parameters to clarify the
request.
Example, a remote can passes an argument to a television set to
change channel to a particular channel or the reduce the volume by
one unit
Object Oriented Programming Design
Principles
Relationships (inheritance and association)
Inheritance
Classification looks at the shared attributes and behavior to create or
describe classes of objects.
Example, you can say that lizards, crocodiles, chameleons may belong
to a class known as reptiles
All reptiles shares attributes such as size and color and behavior such
as laying of eggs
Individual objects of the same type are linked hierarchically to an
abstract super class.
Subtype defines relationships between similar objects.
Sub types are about inheritance or generalization.
Sub types forms relationship “is a” or “a kind of “relationship with
its super classes.
For example: a bus is a kind of vehicle just as a car is also a vehicle.
Object Oriented Programming Design
Principles
Association
Association represents a relationship between different
objects.
For example, a customer may rent a number of videos,
a person works in a company, a company has a number
of offices, etc
There is a line of label between objects called role
name to state the relationship between objects.
The addition of arrow heads to the association’s lines
show the direction in which messages flow which can
either be unidirectional (moves in one direction only)
or bi-directional (moves in both directions between
objects).
Object Oriented Programming Design
Principles
Multiplicity
Multiplicity is concerned with how many
objects may be involved in a relationship
Polymorphism
Polymorphism knows that each object knows
that each object knows how it is supposed to
perform an operation even though it may have
the same name as another object’s operations
End…
End of chapter 1