Programming Methodology
Introduction :
WHAT IS PROGRAMMING METHODOLOGY???
The approach to analyze complex problems, planning for software development and
controlling the development process is called progamming methodology.
WHAT IS A PROGRAM?
A computer program is a sequence of instructions written using a programming
language to perform a specific task by the user.
Here, two terms are used :
1. Instructions
2. Programming
These two terms play an important role for creating an efficient program.
A computer program can be made by using different computer languages such as C+,
Java, Python, V.B. Net etc.
A computer program is also called a computer software which ranges from two lines to
millions of lines of instructions.
NOTE : A program written in programming language is also called a source code.
WHAT IS PROGRAMMING?
The act of writing the code using some programming languages by the programmer or
developer is known as programming.
WHO IS A PROGRAMMER?
A user or developer who writes a program to do some specific task for the customer
according to his or her requirement is known as a programmer.
WHAT IS THE DIFFERENCE BETWEEN A PROGRAMMER AND A DEVELOPER?
A programmer will focus entirely on writing the software code where as a developer
will take care of the project that a client request and let you know what the software
needs to do to get the desired output.
WHAT ARE THE CHARACTERISTICS OF A GOOD PROGRAM??
1. EFFICIENT :
A program is said to be efficient if it requires less memory space, execution speed
takes less time and it takes less efforts while writing a program.
A programmer must take care that a program should utilise less memory.
2. PORTABILITY :
Portability means the ability of a program to run on different platforms i.e. to run on
every machine without changing.
3. READABILITY :
The program must be written in such a way that it makes other programmer to follow
the logic of the program without much efforts.
4. FLEXIBILITY :
It means a program should be able to handle most of the changes without effecting
the whole program.
5. GENERALITY :
It means a program should be general.
If a program is developed for a particular task then it will be the same for other tasks
with the minimal changes.
6. MAINTENANCE :
It means to maintain the program for future use.
It is error free and it can produce the desired result according to the need of the user.
7. ROBUSTNESS :
By the robustness of a program, we mean to say that if an error occurs in a program
then appropriate messages or feedbacks are received so that the error can be located
easily.
8. TESTABLE :
It is one of the most important characteristic of a good program.
It means that the program should be easy to test for correctness.
9. SECURE :
It is one of the most important characteristic of a good program.
It means that the program should protect the user's data from unauthorised access or
modification.
10. REUSABILITY :
Reusability is one of the important characteristics of a good program.
Code segment or modules that can perform common task should be designed in a way
that allows them to be reused in different parts of the program or even in other
projects.
ALGORITHM :
An algorithm is defined as step by step procedure to solve a particular problem.
Before making a program for a software, we have to plan for making a program for
that software.
This plan before making a software or program is known as an algorithm.
It is compulsory to make an algorithm before creating a software.
Hence, an algorithm should be formed before writing the code of a software.
NOTE : An algorithm will be converted into a program to make a software.
FLOWCHART FOR ALGORITHMS :
The pictorial representation of an algorithm having a sequential flow is known as a
flowchart.
Some symbols which are used in flowchart are:
Start & Stop
Input & Output
Decision box
Connector
Arrows
TOP DOWN OR MODULAR APPROACH :
In top down or modular approach, a lengthy program is divided into smaller parts or
segments and each such part is known as a module.
In this approach, a lengthy program breaks down into smaller programs to increase
the readability, usability and maintainability.
ADVANTAGES OF MODULAR PROGRAMMING :
1. FASTER DEVELOPMENT :
It a lose faster development as each module can be developed in parallel and
therefore reduces time.
2. REUSABILITY :
In modular programming, modules can be reused. It allows the user to reuse the code
without typing the whole program.
3. FASTER TESTING :
As each medul is to be tested independently testing is faster and more robust.
4. EASY DEBUGGING :
Modular programming makes the bugging and maintenance of program easier. In this
approach we can easily debug the lines of the code.
5. LESS COMPLEXITY :
Modules are smaller and have lower level of complexities so they are easy to
understand.
6. TIME AND SPACE :
Modular programming approach also reduces the time and space complexity.
DOCUMENTATION :
Documentation means to organised the data in the form of written text, audio or a
video that describe the software or program to its user.
In various stages of development, documentation maybe created for different users,
programmers or administrators.
This programming document approach makes it easier for the user, programmer or
administrator to analyse the whole software.
TYPES OF DOCUMENTATION :
1. INTERNAL DOCUMENTATION :
The internal documentation explains the details of the program by using comments
place inside the program.
The internal documentation should be minimal and include the following :
(a) A block of comment should be placed at the head of every function or method.
(b) It also explain between the line of code.
2. EXTERNAL DOCUMENTATION :
It is a documentation or a user guide and sometimes include the detailed description
of the software or the program.
External documentation is a written description i.e. a written text, audio video or a
video documentation to describe the software used by the customer.
3. USER DOCUMENTATION :
User documentation, also known as end user documentation, is a type of technical
documentation that helps users understand how to use a product or service.
It can include information on how to install, use and troubleshoot a product.
4. PROGRAM DOCUMENTATION :
In modular programming documentation is very important because various modules
are developed by various teams and each team has its own documentation for their
own module.
ADVANTAGES OF PROGRAM DOCUMENTATION :
(a) By making a documentation for every module, maintenance will be easy.
(b) Documentation improves the quality of programs specially by internal
documentation.
(c) It keeps track of all the parts of the program to analyse it and find out the error if it
occurs
.
COMMENTS :
A comment is defined as a non executable part of a program, which are written by a
programmer to explain the source code and their different functions like where we
have to use function, constructor, inheritance etc.
It is also known as internal documentation.
Comments are used by # symbol.
TYPES OF COMMENTS :
1. Single line comments.
2. Inline comments.
3. Multiline comments.
1. SINGLE LINE COMMENT :
It is a type of comment which is used as a single line to explain the details of the code.
EXAMPLE :
#x,y,z are variables of integer type.
x=20
y=30
z=40
C=x+y+z
Print(C)
2. INLINE COMMENT :
It is a type of comment which is placed inside the line of the code to explain a
particular part or portion of a program.
EXAMPLE :
a = int (input(''enteranumber''))
b=a*a
Print (b)
It is a square of number 'a' and variable 'b' was the square of the number.
3. MULTILINE COMMENTS :
It is a type of comment in which we have two or more non executive statement or non
executable lines to explain the documentation of the program.
EXAMPLE :
# Input is a function.
# Print is a function.
# a is variable of integer type.
a = Int(Input("enter a number"))
b = a*a*a
Print(b)
PROGRAM MAINTENANCE :
All the activities that occur after the compilation of a program to verify the program's
high accuracy and get the desired output is known as program maintenance.
It is not a part of program implementation but plays an important role to get the
desired output with high accuracy.
The cost of the program maintenance is much more than the cost of the program
developer.
FEATURES OF PROGRAM MAINTENANCE :
1. Program maintenance is used for finding and correcting the errors to make a
program bug free.
2. Modification in a program will be easier with the high program maintainability.
3. The main feature of program maintenance is to reduce or remove useless part of a
code.
4. The most important feature of program maintenance is to update new features and
functions to make the program more reliable.
DEBUGGING :
The process of finding errors or bugs and then fixing them in any software is known as
debugging.
In short debugging is the most important technique used to remove the number of
errors present in a program.
It includes the steps to identify the errors, finding the source of error and then
correcting the problem to make the program error free.
STEPS TO BE FOLLOWED IN DEBUGGING :
1. IDENTIFY THE ERROR :
This step in debugging process is used to identify the error or bug in a program to
minimise the wastage of time of a program.
It is the first step in debugging process which identifies the existing error or bug.
2. IDENTIFY THE LOCATION OF ERROR :
The exact location of the error should be found to fix the bug faster and execute the
program to get the desired result.
3. ANALYSING THE ERROR :
In this step, we analyse the error to understand the type of bug and reduce number of
errors.
4. PROVE THE ANALYSE :
Once the error has been analysed, we need to prove what type of bug it is and how it
is resolved.
5. COVER THE DAMAGE :
The bugs can be resolved in this step by making the appropriate changes in the code
and move on to the next stage of the code to validate it.
6. FIX AND VALIDATION :
This is the final stage of debugging process in which we check all the new errors or
changes in a program by compiling it again.
If any error is found again then the steps of the debugging process continues in a
sequence and if it is not found then the code is executed to get a desired result.
ERRORS :
An error is a mistake or fault or flaw that arises in a program which stops the execution
of the program.
An error is also called a bug.
An Error is defined as a message to the user or programmer about any type of
problem or fault in the program.
TYPES OF ERRORS :
1. Syntax error.
2. Semantic error.
3. Logical error.
4. Runtime error.
5. Compile time error.
1. SYNTAX ERROR :
It is a type of error which is syntatically not correct.
It arises due to the fault of human being.
If a user follows in correct syntax, a Syntex error occurs in the program.
This error is generally indicated at the time of compilation that's why it is also known
as compile time error.
EXAMPLE :
Number = 5
If number > 0
Print ("positive number")
Else
Print ("negative number")
Here in the above program if-else statement is used and in the statement or in our
program ; (colons) with the condition are missing which violets the rules of writing
syntax that's why it is a syntax error.
2. SEMANTIC ERROR :
When the program has no Syntax error, it will compile and run correctly but will not
give the desired output as the logic is not correct. These errors totally depend upon
the logical thinking of the programmer.
These errors are also called logical errors.
EXAMPLE :
a+b+c = d
It is symmetically incorrect.
The expression of left occurs in the right side and expression of right occurs in the left
side.
>>>P = Int(Input("enter principle amount"))
R = Int(Input("enter rate of interest"))
T = Int(Input("enter time"))
P×R×T/100 = S
Print (S).
Which is incorrect.
3. LOGICAL ERROR :
It occurs in a program when we write wrong formula in a program or logic is incorrect.
We mean to say that the code is synthetically incorrect and produces unexpected
results.
OR
If the syntax and other things are correct then also, we may not get the correct or
desired result or output due to some logical issue. This type of issue with the logic in
the program is called logical error.
EXAMPLE :
a=5
b=5
Print (a % b)
Here in the above program we have to divide a and b and want a result of a quotient
but with the sign of % between a and b, we got remainder as a result. That is why it is
called logical error.
4. RUNTIME ERROR :
Errors which occur during program execution (run-time) after successful compilation
are called runtime errors.
One of the most common runtime error is division by zero also known as division error.
The types of errors are hard to find as the compiler doesn't point to the line at which
the error occurs.
EXAMPLE :
a=9
b=0
c = a/b
Print(c)
Here in the above program, a is divided by b which have the value 0 which means a is
divided by 0, which will generate runtime error.
5. COMPILE TIME ERROR :
An error which occurs in a program at the time of compilation is called compile time
error.
The compile time error prevents the program from starting and does not produce the
result until and unless the error is removed from the program.
These errors generally occur when you include this allowed characters in your code.
EXAMPLE :
int #people = 10
Syntatically, these occur when your code is out of order.
EXCEPTIONAL ERRORS :
Exception is an undesirable output or mismatch of data type. Exception is an error
which occurs when there is a mismatch of data type between two or more variable
while doing some operation on it.
TYPES OF EXCEPTIONAL ERROR :
1. TYPE ERROR :
The type error occurs in a program when there is a mismatch of different data type
between two or more than two variables.
EXAMPLE :
a=2
b = 7.5
Print (c)
In the above code we have to variables a and b of different data type value, so we
cannot do any operation on these two variables. Thus it forms type error.
2. VALUE ERROR :
This type of error occurs in a program when we have a wrong value for a particular
variable.
In other words we can say that this error mostly run in predefined or user defined
function.
EXAMPLE :
a = Input ("enter a number")
r = [Link](a)
Print (x)
In the above code [Link] function have string value but it accept integer or float values
only. Thus, it is known as value type error.
3. NAME ERROR :
Name error occurs in a program when there is a wrong name declaration in a
particular program.
EXAMPLE :
x=5
y=7
z = (x+y)
Print (a)
4. ZERO DIVISION ERROR :
It is an exceptional error which occurs in a program when we divide a number by zero
and it gives us an error known as 0 division error.
This error comes under run time and logical error.
EXAMPLE :
a = Int(Input("enter first number''))
b = Int(Input("enter second number''))
c =a/b
Print (c)
Enter first number 2
Enter second number 0.
5. INDEX ERROR :
It is that type of error which occurs in a program when we have invalid index number
while accessing the value from string, list or tuple.
EXAMPLE :
L = [1,2,3,4,5]
Print (L 10)
6. KEY ERROR :
Key error occurs in a program when we have a wrong or invalid key at that time.
EXAMPLE :
D = {1:"ABC" 2: "DEF"}
Print (D 10)
7. OVERFLOW ERROR :
Overflow error occurs in a program when there is a large value obtained by any
seperation performed on one or more variables.
This large value obtained cannot be store in normal variable, int or float data type
variable and it can cause overflow error.
EXAMPLE :
a = Int(Input("enter first number"))
b = Int(Input("enter second number"))
Output
Enter first number = 100
Enter second number = 29.5
Value overflow in variable 'b'.
In other words,
in overflow error in the program we have two variables a and b to perform operation
but while entering the value by mistake we can give decimal value or float value in
variable b. This value cannot be hold by variable b because it can hold only integer
value whose memory size is 2 bytes and float memory size is 4 bytes. Hence, it is
called overflow error exception.
PRETTY OR FREE FORMATING
Pretty formating is a type of printing format which is used to convert and present the
source code or other objects in an attractive way.
In other words we mean to say that it is used with the help of printer that takes line of
code and print them in an attractive manner representing the characters with the
break and indentation to make the code very attractive.
Free formating is used by publishers. It is a free standard which can be any set of
specification that is like wise both published and available with or without any cost and
any restrictions.
CONCEPT OF STRING, LIST, TUPLE AND DICTIONARY :
STRING :
String is a collection of characters which are enclosed in double codes.
With the help of print function we can display string on the screen.
EXAMPLE:
>>> s = "ABC"
Print (s)
s = Input ("enter your name")
Print (s)
LIST :
A list is a collection of values and values present in list are separated by commas.
Values of list are enclosed in square brackets and with the help of print function we
can display a list.
EXAMPLE :
L = [1,2,3,4,5]
Print (L)
It is also known as, separated values.
TUPLE :
Tuple is a collection of values which are separated by commas and are enclosed within
parenthesis.
With the help of print function we can display a tuple.
EXAMPLE :
T = (1,2,3,4,5)
Print (T)
DICTIONARY :
In dictionary we can use key and value which are in closed in curly braces and
separated by commas.
We can use call and with key and value and with the help of print function we can
display the dictionary key.
EXAMPLE :
D = {1:"ABC", 2:"DEF"}
Print (D 1 )
INDENTATION IN PYTHON :
Indentation is used in programming to give appropriate spaces while writing a code in
a program.
If an user gives more space while entering the code, then an indentation error can
occur in the program.
EXAMPLE :
If (a >. b)
Print ("a is greater")
In the above program, while writing the condition in the program more space is
provided between a and b variable due to which an indentation error occurs.
LOOPING STATEMENT :
Looping statements are also known as iteration statements.
The iteration statements or repetition statements allow a set of instructions to be
performed repeatedly until a certain condition is completed.
In other words, iteration statements are also known as loops or looping statements.
Python provides two kinds of loops:
1. Far loop
2. While loop
COUNTING LOOP :
The loop that repeats for a certain number of times is called a counting loop.
Python for loop is a counting loop.
CONDITIONER LOOP :
The loop that repeats until a certain thing happens is called a conditional loop.
They keep repeating as long as some condition is true.
ENTRY CONTROL LOOP :
If the condition is tested before executing the loop bodies that is before entering in the
loop, the loop is called entry control loop.
EXIT CONTROL LOOP :
If the condition is tested after executing the loop body at least once, then the loop is
called exit control loop.
Far loop is entry control loop. In python, far loop is designed to process the item of any
sequence such as a list or a string one by one.
In python we can use two data types, int and float where int = integer and float =
decimal value.
Integer takes two bytes of memory and floor takes 4 bytes of memory.
In python, why default value is displayed in string.
NOTE : Far loop is also called pre conditional loop and while loop is also called post
conditional loop.
IF - ELSE STATEMENT:
In if statement, first of all conditions will be checked and if the condition is true then
the body will be executed.
NOTE :
( ) is called parenthesis.
{ } Is called delimiters or curly bracket.
[ ] Is called scare bracket or some script.
...... Is called ellipsis.
# is used to write a comment in python.