0% found this document useful (0 votes)
6 views

w1-w2 Programming_basic (1)

The document provides an overview of computer programming fundamentals, including the history of computers, definitions of programming languages, and the programming development life cycle (PDLC). It outlines the types of programming languages, their advantages and disadvantages, and details the steps involved in program development from planning to maintenance. Additionally, it discusses the importance of documentation and various design tools used in programming.

Uploaded by

fauwazfauzi
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

w1-w2 Programming_basic (1)

The document provides an overview of computer programming fundamentals, including the history of computers, definitions of programming languages, and the programming development life cycle (PDLC). It outlines the types of programming languages, their advantages and disadvantages, and details the steps involved in program development from planning to maintenance. Additionally, it discusses the importance of documentation and various design tools used in programming.

Uploaded by

fauwazfauzi
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 62

PROGRAMMING BASIC

TOPIC 1

CSC 1383 PROGRAMMING FUNDAMENTALS 1


1.1 HISTORY OF
COMPUTER AND
PROGRAMMING
LANGUAGES
HISTORY OF COMPUTER AND PROGRAMMING LANGUAGES
• What is computer?
• A computer is a machine that can be instructed to carry out sequences of arithmetic or
logical operations automatically via computer programming
6. Digital
Computer-
ENIAC (Electronic
Numerical
1. Jacquard
Machine
❑ Jacquard machine – automated loom invented; device fitted using punch
Integrator and
Computer) card to simplifies the process of manufacturing textile
❑ Abacus – device to help in getting the result of arithmetic operation
❑ Automata – 3 dolls built by the Jacquet- Droz family. The three doll that
can read instruction; that can play music, that can do drawing and can
write a letter.
5. Analog
computer 2. Abacus ❑ Difference engine was an autoptic mechanical calculator designed by
Charles Babbage.
❑ Analog computer – machine that works with analog input such as
voltage, temperature or pressure
❑ Digital computer – works with input that can be presented by the
4. Difference numbers
Engine / 3. automata
Analytical Engine ❑ ENIAC – the first programmable, electronic, general purpose digital
computer.
COMPUTER PROGRAM

• A program is a set of instructions following the rules of the chosen


language.
• A program /application or software, is a set of instructions that
process input, manipulate data, and output a result. For example,
Microsoft Word is a word processing application that allows users
to create and write documents.
• A program is like a recipe, it contains a list of ingredients (called
variables) and a list of directions (called statements) that tell the
computer what to do with the variables.
• Instructions must be written in a way that the computer can
understand.
• Programming languages are used to write programs.
• DEFINITION OF PROGRAM

DEFINITION • A set of instructions that tells a computer to perform tasks.



• COMPUTER PROGRAMMING
• Computer programming is the process of writing, testing,
debugging/troubleshooting, and maintaining the source code of
computer programs.
• This source code is written in a programming language like Phython,
• C++, JAVA, Perl etc.

• COMPUTER PROGRAMMER

• A programmer is someone who writes computer program.


• Computer programmers write, test, and maintain programs or
software that tell the computer what to do.
DEFINITION OF PROGRAMMING LANGUAGE

A set of words, symbols and A vocabulary and set of Programming languages can be
codes that enables a programmer grammatical rules (syntax) for used to create computer
to give instruction to a computer. instructing a computer to perform programs.
specific tasks.

The most basic (called low-level) The high-level languages (such as


The term programming language computer language is the machine Basic, C, Java) are much simpler
usually refers to high-level language that uses binary ('1' and (more 'English-like') to use but
languages, such as BASIC, C, C++, '0') code which a computer can run need to use another program (a
COBOL, FORTRAN, Ada, and (execute) very fast without using compiler or an interpreter) to
Pascal. any translator or interpreter convert the high-level code into
program, but is tedious and the machine code, and are
complex. therefore slower.
There are three types of programming
language:
TYPES OF
• Machine language (Low-level language)
PROGRAMM • Assembly language (Low-level language)
ING • High-level language
LANGUAGE
Low-level languages are closer to the
language used by a computer, while high-level
languages are closer to human languages
LOW LEVEL LANGUAGE
MACHINE LANGUAGE

• The fundamental language of the computer’s processor, also called Low


Level Language.
• Machine language is a collection of binary digits or bits that the
computer reads and interprets.
• Also known as machine code or object code, is the elemental language of
computers.
• Machine language is the only language a computer is capable of
understanding.
• All programs are converted into machine language before they can be
executed.
• Is the natural language of a computer.
• Consists of combination of 0’s and 1’s that represent high and low electrical
voltage.
• Machine language is a collection of binary digits or bits that the computer
reads and interprets.
• Programming language that can be directly understood and obeyed by a
machine (computer) without conversion (translation).
• machine languages are almost impossible for humans to use because they
consist entirely of numbers.
LOW LEVEL LANGUAGE
•Examples of code:
1110100010101 111010101110

Example:
•Let us say that an electric toothbrush has a processor and main memory.
•The processor can rotate the bristles left and right, and can check the on/off switch.

The machine instructions are one byte long, and correspond to the following machine operations:
LOW LEVEL LANGUAGE

ADVANTAGE DISADVANTAGE

Instructions are readily understood by the Instructions are extremely cryptic and difficult to
computer learn

Programs are lengthy - a single instruction


Ready for immediate execution
corresponds to one operations at the machine level
ASSEMBLY LANGUAGE
A program written in assembly language consists of a series of instructions
mnemonics that correspond to a stream of executable instructions, when
translated by an assembler, that can be loaded into memory and executed. Example :

Assembly languages use keywords and symbols, much like English, to form a
programming language but at the same time introduce a new problem.

The problem is that the computer doesn't understand the assembly code, so we
need a way to convert it to machine code, which the computer does
understand.

Assembly language programs are translated into machine language by a


program called an assembler.
ASSEMBLY LANGUAGE

ADVANTAGE DISADVANTAGE

Not readily understood by computer, thus need to be


translated to machine language before executed
Instructions are easier to learn compared to
machine language
Programs are lengthy - a single instruction corresponds to
one operations at the machine level
HIGH LEVEL LANGUAGE
• High-level languages allow us to write computer code
using instructions resembling everyday spoken
language (for example: print, if, while) which are then
translated into machine language to be executed.
• Programs written in a high-level language need to be
translated into machine language before they can be
executed.
• Some programming languages use a compiler to
perform this translation and others use an interpreter.
• Examples of high level language : FORTRAN,
COBOL, BASIC, Pascal, Ada, C , Phyton
HIGH LEVEL LANGUAGE
ADVANTAGE DISADVANTAGE

Instructions are easier to learn compared to


low-level languages

Shorter program - a single instruction


corresponds to many operations at the Have to be converted to machine-language
machine level before they can be executed

Machine-independent - can run on different


types of computers and operating systems
COMPARISON
EXAMPLE OF HIGH LEVEL LANGUAGE
1.2 PROGRAM
DEVELOPMENT
LIFE CYCLE
SYSTEM DEVELOPMENT LIFE CYCLE (SDLC)

PROVIDES A STRUCTURED FRAMEWORK IS THE BIG PICTURE OF CREATING AN THE APPLICATION USUALLY CONSISTS
THAT GIVES AN IDEA, HOW TO BUILD A INFORMATION SYSTEM THAT HANDLES OF MANY PROGRAMS.
SYSTEM A MAJOR TASK OF APPLICATION.
PROGRAM DEVELOPMENT LIFE CYCLE (PDLC)

Is a process used in software Very similar/replicate the


engineering to manage the Software Development Life Cycle
development of software (SDLC)
programs

PDLC is an iterative process that It provides an organized plan for


allows for feedback and breaking down the task of a
adjustment to be made at each program development into
phase, to ensure that the final manageable chunks, each of which
product meets the needs or must be completed before moving
requirements. on to the next phase.
SOFTWARE DEVELOPMENT LIFE
CYCLE

PDLC AND SDLC HAVE A VERY SIMILAR PHASE.


PROGRAM DEVELOPMENT LIFE CYCLE (PDLC)
PHASES
Planning –the goals and objectives of the program are defined, and plan is developed
to achieve them. Identify the resources required and determine the budget and schedule
for the program

• Analysis – the requirements for the program are defines and


analyzed. Identify the needs and requirements for the program.

• Design – the program’s architecture and design are developed.


Include a detail design of program components and interfaces.
• Implementation – the program is developed and coded. Include
writing program's source code.

• Testing – the program is tested to ensure that it meets the


requirements and is free from defects.

• Deployment – product installation and customer acceptance for


the software, made it available to users

• Maintenance – after the deployment, the program is maintained


by fixing any bugs and errors that are found and updating the
program to meet changing requirements,
There are seven (7) steps in PDLC:

Planning

Problem Analysis (Defining the problem)

Designing a solutions (Planning the solution)

STEPS IN PDLC Implementation (Coding the Program)

Testing and debugging the Program

Deployment

Maintaining the program


1. PLANNING
• Involve gathering requirements from stakeholders
and analyze them to plan the project
• the goals and objectives of the program are
defined, and a plan is developed to achieve them.
• This includes identifying the resources required,
identify risks and determining the budget and
schedule for the program.
Investigation of the cause, issues or failure

The task of defining the problem consists of identifying


2. PROBLEM what you know (input – given data) and what you want to
obtain (output- the result).
ANALYSIS
(DEFINING THE Specifying the problem requirements forces you to state
the problem clearly and to gain a clear understanding of
PROBLEM) what is required for its solution.

The objective is to eliminate unimportant aspects and to


focus on the root problem.

It involves identifying the problem by using the Input-


Process-Output (IPO) Model
PROBLEM ANALYSIS : INPUT PROCESS
OUTPUT (IPO) ANALYSIS MODEL

• Approach used for describing the structure of an


information processing program or other process
a) INPUT - What is the data needed? Inputs are the data
inserted into the program.
b) PROCESS - How to process data, what formula to use?
c) OUTPUT - What to produce? The expected result
after the processing.
PROBLEM STATEMENT 1
Converting the Fahrenheit(F) temperature into Celsius
(C))temperature
Problem Analysis :
To convert from Fahrenheit to Celsius temperature, we
need to use the formula (F-32) * 5/9.
• Input : the Fahrenheit temperature
• Process : C = (F-32) * 5 / 9
• Output : the Celsius temperature
PROBLEM STATEMENT 2:

• Calculate the area of triangle.


• Problem Analysis :
• To calculate the area of triangle (T) we need to
use the formula ½ X base (B) X height (H)
• Input : Base (B), Height (H)
• Process : T = ½ * B * H
• Output : T (Area of triangle)
3. • The first step to design solution is to identify main
routine (the program major activity), divide it into
DESIGNING various components, then divide into the smaller
part called modules.

A • For each module programmer draw a conceptual


plan using appropriate design tool to visualize how
the module assign a job.
SOLUTIONS • Design tools that can be used :

(PLANNING • Structure charts


• Algorithms
THE • Flowcharts
• Pseudocode
SOLUTION) • Decision Table
* For this course only Algorithms, Flowcharts and
Pseudocode will be discussed in detail.
DESIGN TOOLS-
STRUCTURE CHART
• Also called Hierarchy chart, show
top-down design of the program.
• Each box indicate a task that
program must accomplish.
• The top module, called the main
module or control module
DESIGN TOOLS-
ALGORITHMS
• A step-by-step description of how to arrive
at a solution in easier way
• A sequence of a finite number of steps
arranged in a specific logical order which
produces a solution for a problem.
• Are not restricted to computer world only,
in fact we use it in everyday life.
• Example of algorithms to make a cup of
tea
DESIGN TOOLS-
PSEUDOCODE
• Informative text or annotations written in plain English
used to represent an implementation of algorithms.
• Helps programmers to plan and communicate their ideas
before diving into actual code.
• Allows the user to focus on the program logic without
having to be concerned yet about the precise syntax of
a particular programming language.
• Example : Finding the largest number between two
numbers
DESIGN TOOLS-
FLOWCHART
• Is a diagram that shows the logic of
the program.
• Can also be considered as a pictorial
representation of algorithm.
• Each step of algorithms is represented
in a form of various shapes of boxes
with logical indicated by
interconnecting arrows.
DESIGN TOOLS-
DECISION TABLE
• Visual representation that specifies which
actions to do based on given conditions.
• A special kind of table, which is divided
into four parts by a pair of horizontal and
vertical lines.
• Used to settle different combinations of
inputs with their corresponding outputs
4. IMPLEMENTATION
(CODING THE PROGRAM )

The next step is to code the program – that is, to


express the solution in a programming language.

Translate the logic from the flowchart or pseudocode


or some other tool to a programming language.

A programming language is a set of rules that


provide a way of instructing the computer what
operation to perform.

The example of programming languages are


PYTHON, BASIC , COBOL , FOTRAN , C, C++,
Code to add two numbers using PYTHON VISUAL BASIC, PASCAL and some other example.
5. TESTING AND DEBUGGING THE PROGRAM

• After the coding the program you must


prepare to test it in the computer.
• Testing means running the program,
executing all its instructions /functions
and test the logic by entering sample
data to check the output.
• Debugging is the process of finding
and correcting program code mistake.
Syntax Errors
TYPES OF ERROR
IN
PROGRAMMING
Logical errors

Runtime errors
SYNTAX ERROR

• Type of errors that occur when


code violates the rules of the
programming language such as
missing semicolons, brackets or
wrong indentation of the code
LOGICAL
ERROR
• Type of bug that occur when a
program runs without crashing but
produces incorrect or unintended
results.

• Mistake in the program's logic that


lead to incorrect behavior or
output, despite the syntax being
correct.
RUN TIME
ERROR
• Errors caused by unexpected
condition encountered while
executing the code that prevents
the code to compile.

• These can be null pointer


references or array out of bound,
deploy (Install) new application for
customers to use

the program is kept under watch till the


user gives a green signal to it

6. DEPLOYMENT After deployment, the launch may involve


marketing your new product or service so
people know about its existence.

If the software is in-house, it may mean


implementing the change management
process to ensure user training and
acceptance.
7. MAINTAINING

Involves updating an Operations refer to the day


existing software product to Include adding new to-day running a software
fix bugs and ensure features or functionality to product or service such as
reliability. a current product performing a backups and
other administrative tasks
DOCUMENTATION : INTERNAL
DOCUMENTATION
a) Internal documentation
• Consists of remarks written with instruction to
explain what is being done in the program.
• Proper internal documentation ensures that the
new programmer will be able to learn about the
program in the least amount of time.
• It should include such thing as people who have
work on the program, an abstract of the program,
variable usage, remarks or comment written in the
program code, notes about the development of the
program and anything else that will enable the new
programmer to understand this program in the
least amount of time.
DOCUMENTATION : EXTERNAL
DOCUMENTATION
a) External documentation
• Is made up of the manuals or helps menus written about the solution.
• Is for the user of the program.
• The end user will use the program to help solve problems.
• Proper external documentation ensures that the end user will have good
instruction in order to learn to use this program in the least amount of
time.
• It should include such things as tutorials, input definitions, usage
instruction, installation instruction, command explanation and anything
else that will allow the end user to learn to use this program in the least
amount of time.
No. Internal documentation External documentation

1. Internal documentation is written in a External documentation is written in a


program as comments. place where people who need to use the
software can read about how to use the
software.
2. Internal documentation would be External documentation would be things
comments and remarks made by the like flow charts, UML diagrams,
programmer in the form of line comments requirements documents, design
documents etc.
3. Internal Documentation is created within External Documentation is created by the
the programming department and shows user and Programmer/System Analyst.
the design and implementation of the
project (flow charts, UML diagrams,
design documents, etc.).
1.3
PROGRAMMING
PARADIGM
A programming paradigm is a fundamental
style of computer programming.

WHAT IS
Paradigms differ in the concepts and methods
PROGRAMMING used to represent the elements of a program
PARADIGM? (such as objects, functions, variables, constraints).

And also steps that comprise a computation


(such as assignations, evaluation, continuations,
data flows).
Different approaches to programming have developed over time.

The concept of a "programming paradigm" as such dates at least to 1978.

HISTORY The lowest-level programming paradigms are machine code.

In the 1960s, assembly languages were developed followed by


development of procedural languages.

Following the widespread use of procedural languages, object-oriented


programming (OOP) languages were created and followed by many more.
• Programming paradigm is an approach or method to solve
problem using some programming language.
• There are lots for programming language; all of them need to
follow some strategy when they are implemented, and this
methodology/strategy is paradigms.

PARADIGM • COMMON PROGRAMMING PARADIGMS:


Imperative or Procedural Programming
Object-Oriented Programming
Functional Programming
Declarative Programming
IMPERATIVE OR PROCEDURAL
PROGRAMMING PARADIGM
• Imperative programming is a programming paradigm that uses statements that change a
program's state.
• In much the same way that the imperative mood in natural languages expresses commands.
• An imperative program consists of commands for the computer to perform.
• Imperative programs describe the details of HOW the results are to be obtained.
• HOW means describing the Inputs and describing how the Outputs are produced.
• Examples are: C, C++, Java, PHP, Ruby etc.
• Advantages
➢ low memory utilization
➢ relatively efficient
➢ the most common form of programming in use today.
• Disadvantages
➢ difficulty of reasoning about programs
➢ difficulty of parallelization.
➢ As there are so many procedural languages, a programmer tends to have to specialise in a
particular language in order to get work. A COBOL specialist has a different skills to a 'C'
specialist.
OBJECT ORIENTED
PROGRAMMING PARADIGM
• Object-oriented programming (OOP) is a programming paradigm based on the concept of "objects",
which may contain data, in the form of fields, often known as attributes; and code, in the form of
procedures, often known as methods.
• There is significant diversity of OOP languages, but the most popular ones are class-based, meaning
that objects are instances of classes, which typically also determine their type.
• In OOP, computer programs are designed by making them out of objects.
• Examples are: C++, C#, Java, PHP, Python.

• Advantages
➢ Conceptual simplicity
➢ Faster development
➢ Increased productivity
• Disadvantages
➢ Can have a steep learning curve
➢ Larger program size than procedural programs.
FUNCTIONAL PROGRAMMING
PARADIGM

• Functional programming is a subset of declarative programming.
• Programs written using this paradigm use functions, blocks of code intended to
behave like mathematical functions.
• Functional languages discourage changes in the value of variables through
assignment, making a great deal of use of recursion instead.
• Examples are : F#, Haskell, Lisp, Python, Ruby, JavaScript etc.
• Advantages
➢ Small and clean syntax
➢ Better support for reasoning about programs
➢ They allow functions to be treated as any other data values.
➢ They support programming at a relatively higher level than the imperative
languages
• Disadvantages
➢ Requires Lot of Memory
➢ Functional languages use more storage space than their imperative cousins
IMPERATIVE FUNCTIONAL

IMPERATIVE VS FUNCTIONAL PARADIGM


DECLARATIVE /LOGIC
PROGRAMMING PARADIGM
• Declarative programming is a programming paradigm—a style of building the structure and
elements of computer programs—that expresses the logic of a computation without
describing its control flow.
• Declarative programming focuses on what the program should accomplish.
• Declarative programming often considers programs as theories of a formal logic, and
computations as deductions in that logic space.
• Examples are: Miranda, Prolog, etc.
• Advantages
➢ Short, efficient code
➢ Can be implemented using methods not yet known at the time of programming
➢ Easy optimization as implementation is controlled by an algorithm
➢ Maintenance possible independent of application development
• Disadvantages
➢ Sometimes hard to understand for external people
➢ Based on an unfamiliar conceptual model for people (solution state)
➢ Hard to take characteristics of individual applications into account during programming
DECLARATIVE /LOGIC PROGRAMMING
PARADIGM

LOGIC PROGRAMMING UDINN


TRANSLATOR COMPILE

INTERPRETER
• Translator - You eventually need to convert your program into machine
language so that the computer can understand it.
• Assembler converts program written in assembly language to machine
code
• Compiler is to transform a program written in a high level programming
language from source code into object code.
• This can be done by using a tool called compiler.
• A compiler reads the whole source code and translates it into a complete
machine code program to perform the required tasks which is output as a
new file.

• Interpreter is a program that executes instructions written in a high-level
language. An interpreter reads the source code one instruction or line at a
time, converts this line into machine code and executes it.
, Phyton

You might also like