[go: up one dir, main page]

0% found this document useful (0 votes)
14 views22 pages

Chapter 2.docx C STR Prog

Chapter 2 discusses program development and design, outlining the collaborative and iterative process organizations use to create software programs. It details the program development cycle, which includes analyzing the problem, designing solutions, coding, testing, and documenting. Various programming techniques such as structured programming, modular programming, and object-oriented programming are explored, along with the importance of flowcharts and algorithms in the design process.

Uploaded by

ronoh71
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views22 pages

Chapter 2.docx C STR Prog

Chapter 2 discusses program development and design, outlining the collaborative and iterative process organizations use to create software programs. It details the program development cycle, which includes analyzing the problem, designing solutions, coding, testing, and documenting. Various programming techniques such as structured programming, modular programming, and object-oriented programming are explored, along with the importance of flowcharts and algorithms in the design process.

Uploaded by

ronoh71
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 22

CHAPTER 2: PROGRAM DEVELOPMENT AND DESIGN

Introduction to program development


Program development in computing; refer to the coding of an individual software program or to the
creation on an entire information system and all related software.
Program design is the activity of progressing from a specification of some required program to a
description of the program itself.

It is the process that organizations use to develop a program. Ideally, the process is collaborative,
iterative, and tentative—stakeholders work together to repeat, review, and refine a program until they
believe it will consistently achieve its purpose.

A program design is also the plan of action that results from that process. Ideally, the plan is
developed to the point that others can implement the program in the same way and consistently achieve
its purpose.
Program Development Cycle
1. Analyze – Define the problem.
You must have a clear idea of what data (or input) is given and the relationship between the
input and the desired output.

2. Design – Plan the solution to the problem.


Find a logical sequence of precises steps that solve the problem (aka the algorithm). The logical
plan may include flowcharts, psuedocode, and top-down chaDesign the interface – Select
objects (text boxes, buttons, etc.).
Determine how to obtain input and how the output will be displayed. Objects are created to
receive input and display output. Appropriate menus, buttons, etc. are created to allow user to
control the program.
3. Code – Translate algorithm into a programming language.
During this stage that program is written.
4. Test and debug – Locate and remove errors in program.
Testing is the process for finding errors. Debugging is the process for correcting errors.
5. Complete the documentation – Organize all materials that describe the program.
Documentation is necessary to allow another programmer or non-programmer to understand
the program. Internal documentation, known as comments, is created to assist a programmer.
An instruction manual is created for the non-programmer. Documentation should be done
during the coding stage.
Programming Techniques
Software designing is very anesthetic phase of software development cycle. The beauty of heart, skill of
mind and practical thinking is mixed with system objective to implement design.
The designing process is not simple, but complex, cumbersome and frustrating with many curves in the
way of successful design.
Here are some approaches:
Structural Programming
• Modular Designing
• Top Down Designing
• Bottom Up Designing
• Object Oriented Programming
The objective of Program design are:
(i) Replace old system: The new system is used to replace old system because maintenance cost is high
in old system and efficiency level low.
(ii) Demand of Organization: The new system is developed and installed on the demand of
organization and working groups.
(iii) Productivity: The new system is installed to increase productivity of company or
organization.
(iv) Competition: The new system is a matter of status also. In the age of roaring competition, if
organization does not cope with modem technology failed to face competitions
(v) Maintenance: The new system is needed to maintain organization status.
1. Structured Programming
This is the first programming approach used widely in beginning. Professor Edsger Wybe Dijkstra
(1960) coins the term Structural Programming. Italian computer scientist C. Bohm and
G. Jacopini (1966) give the basic principal that supports this approach. The structured programming
movement started in 1970, and much has been written about it. It is often regarded as ―goto-less‖
programming, because it is avoided by programmers.
The program is divided into several basic structures. These structures are called building blocks. These are
following:
(a) Sequence Structure: This module contains program statements one after another. This is a very

Sequence Structure

simple module of Structured Programming.


(b) Selection or Conditional Structure: The Program has many conditions from which correct
condition is selected to solve problems. These are (a) if-else (b) else-if, and (c) switch-case

Conditional structure
(c) Repetition or loop Structure: The process of repetition or iteration repeats statements blocks
several times when condition is matched, if condition is not matched, looping process is terminated. In
C, (a) goto, (b) for (), (c) do, (d) do – while are used for this purpose.

Loop Structure
Advantage:
• Problem can be easily described using Flowchart and flowchart can be easily coded into
program because the nature of this technique is like as flowchart.
• The program is easily coded using modules.
• The testing and debugging is easy because testing and debugging can be performed module-
wise.
• Program development cost low.
• Higher productivity, high quality program production.
• Easy to modify and maintain
• It is called “gotoless” programming because use of goto for unconditional branching is strongly
avoided. The goto is a sign of poor program design, so many designing concepts are not favoring
it but it is used in all programming language widely. When more goto is used in program,
program become less readable and its impact is negative in program functionality. So it is saying
about goto:”Never, ever, ever use goto! It is evil”.
Disadvantage:
More memory space is required. When the numbers of modules are out of certain range, performance
of program is not satisfactory.

2. Modular Programming
When we study educational philosophy, the concept of modulation can be clear without any
ambiguity. Rene Descartes (1596-1650) of France has given concept to reconstruct our knowledge by
piece by piece. The piece is nothing, but it is a module of modem programming context.
In modular approach, large program is divided into many small discrete components called Modules.
In programming language, different names are used for it.
For example:
Q-basic, Fortran Subroutine
Pascal Procedure or Function
C, C+, C#, Java Function
It is logically separable part of program. Modules are independent and easily manageable. Generally
modules of 20 to 50 lines considered as good modules when lines are increased, the controlling of
module become complex.
Modules are debugged and tested separately and combined to build system. The top module is called
root or boss modules which charges control over all sub-modules from top to bottom. The control flows
from top to bottom, but not from bottom to top.
The evaluation of modeling is called coupling and cohesion. The module coupling denotes number of
interconnections between modules and module cohesion shows relationship among data or elements
within a module.

Modular Programming

3. Top down Approach


(a) The large program is divided into many small module or subprogram or function or
procedure from top to bottom.
(b) At first supervisor program is identified to control other sub modules. Main modules are divided into
sub modules, sub-modules into sub- sub- modules. The decomposition of modules is continuing
whenever desired module level is not obtained.
(c) Top module is tested first, and then sub-modules are combined one by one and tested.

Top down Approach

Example: The main program is divided into sub-program A, B, and C. The A is divided into
subprogram A1, A2 and A3.The B is into B1, and B2. Just like these subprograms, C is also divided
into three subprogram C1, C2 and C3. The solution of Main program is obtained from sub program A,
B and C.
4. Bottom up Approach
• In this approach designing is started from bottom and advanced stepwise to top. So, this approach
is called Bottom up approach.
• At first bottom layer modules are designed and tested, second layer modules are designed
and combined with bottom layer and combined modules are tested. In this way, designing
and testing progressed from bottom to top.
• In software designing, only pure top down or Bottom up approach is not used. The hybrid
type of approach is recommended by many designers in which top down and bottom up,
both approaches are utilized.
5. Object oriented programming
In the object-oriented programming, program is divided into a set of objects. The emphasis given on
objects, not on procedures. All the programming activities revolve around objects. An object is a real
world entity. It may be airplane, ship, car, house, horse, customer, bank Account, loan, petrol, fee,
courses, and Registration number etc. Objects are tied with functions. Objects are not free for walk
without leg of functions. One object talks with other through earphone of functions. Object is a boss but
captive of functions.

Features of Object oriented Language


• The program is decomposed into several objects. In this language, emphasis is given to the
objects and objects are central points of programming. All the activities are object centered.
• Objects occupy spaces in memory and have memory address like as records in PASCAL and
structure in C language.
• Data and its functions are encapsulated into a single entity.
• Reusability: In C++, we create classes and these classes have power of reusability. Other
programmers can use these classes.
• It supports bottom up approach of programming. In this approach designing is started from
bottom and advanced stepwise to top.
Some technical terms supporting object-oriented languages are:

(i) Abstraction: The abstraction is an important property of OOP. The use of essential features over less
essential features is called abstraction. The following examples will help to understand abstraction.
Example: The computer operators know only to operate computer, but they are unaware to internal
organization of computer.
In OOP, there are many devices used for data abstraction such as class, encapsulation, data hiding etc.
(ii) Class: A class is a collection of similar objects. Objects are members of class. Once a class is
declared, its many members can be easily created in programs. The class binds attributes (data and
functions or methods) of member objects. Examples:

Class employee

char name[30]; float


basic; void getdata();
void show();
};

(iii) Polymorphism: The ability to find in many forms is called polymorphism (Poly: many, Morphe:
shape / form). For instance, + is mathematical operator, it concatenates two strings and give sum of two
digits (numbers). Here, operator + has different behavior for numerical data and strings. Just like it,
once declared function has different meaning that is called function overloading. If operator has
different meaning, it is called operator overloading.
(iv) Encapsulation: The encapsulation is a very striking feature of OOP in which data and function is
bound into single unit. Array, records, structure are also example of low level encapsulation but term
encapsulation is mostly used in object oriented language. The data and function are encapsulated into
class. External world or external function cannot access the data. It can be accessed by its own function
or method encapsulated with it into class. It hides private elements of objects behind public interface.
(v) Inheritance: Inheritance is a hierarchy of class in which some properties of base class is
transferred to derived class. The main types of inheritance are:
(a) Single Inheritance: A derived class (child class or sub class) of single base (super or parent) class is
called single Inheritance.
(b) Multiple Inheritances: A derived class of multiple base classes is called Multiple Inheritance.
(c) Multilevel Inheritance: When derived class is derived from another derived class, such type of
inheritance is called Multilevel Inheritance.

Monolithic Design (architectural style or a software development Design pattern), describes a single-
tiered software application in which the user interface and data access code are combined into a single
program from a single platform. A monolithic application is self-contained, and independent from other
computing applications. The design philosophy is that the application is responsible not just for a
particular task, but can perform every step needed to complete a particular function.
Programming Tools
The programming is a solution of different problems of our real life. If efficient programming tools are
used, problems are effectively solved. We code some instructions to instruct computer for problem
solving purposes. The choice of tools depends on nature of problems.
There are many tools for programmers for programming. For instance, algorithms, flowcharts,
pseudocodes, data dictionary, decision table, data flow diagrams etc are effective tools.
Enough and adequate knowledge of programming tools are essential for programming (Software
development).Flowchart
The pictorial presentation of program is called Flowchart. It is a tool and technique to find out
solution of programming problems through some special symbols. It is a way to represent program
using geometrical patterns. Prior to 1964, every manufactures use different types of symbols, there
was no uniformity and standards of flowcharting. The Standard symbols were developed by
American Standard National Institute (ANSI).
There are two types of Flow Chart:
(a) Program Flow Chart and
(b) System Flow Chart.
Program Flow Chart
(i) Start / Stop: This oval is used to represent START and STOP of program.
(ii) Input/Output: Parallelogram is used to denote input and output of data. We take data
through it and display result also using this symbol.
(iii) Process: Rectangle is used to denote process, formula, increment, and decrement and
assigned value also.
(iv) Pre-defined Process: The predefined process is denoted by this symbol. Example: Sorting and
Display is pre-defined process and represented as:

Pre-defined Process
(iv) Decision box: It is a symbol of decision. All type of decisions is written in it.

(v) Connector: It is used to link to segment of flowchart to complete as one.

(vi) Data flow: It is used to show data flow from one component to other component, one
process to other and one symbol to other symbol.

The John Von Neumann used flowchart to solve problem in 1945 and explained its importance in
program designing.

Illustration: In our everyday life, there is a sequence of works. These sequences of works are called
routine. We all are tied with it. Suppose, we arise early in the morning at 5 0‘ clock, go to toilet, after
coming from toilet, clean hands with soap and water, brush our teeth then take bath. Here, one sequence
of work is formed.

In computer world, programming language is used to solve certain problems. The solution of problem is
a sequence of processes. In one problem, there may be many processes, the flowchart help to arrange
processes in definite order. Suppose, we have to convert Fahrenheit temperature into Celsius, it has
following five steps:

• Step-1: Start
• Step-2: Enter Fahrenheit temperature (F)
• Step-3: Application of formula: C=(F-32)(5/9)
• Step-4: Displaying the result (C)
• Step-5: Stop

These types of processes involved in solution of problem are called Algorithm. It is a stepwise
presentation of problem solution in simple English without using confusing words and phrases.

When we draw flowchart, it is only conversion of steps or algorithm in special symbols.


Flow Chart

Flowchart is like as city map. Travelers or tourists search places of historical importance through city
map. Buildings are built on the basis of building-design (map) drawn by Architect engineers.

Just like it, program is coded on the basis of flowchart. Flowchart is a language free concept, if it is
prepared, any language can be used for program coding. In software development cycle, flowcharting is
one essential phase.

System Flowchart:
System flowchart is a pictorial representation of procedure flows inside and outside of the systems. It
is also called Data Flow Chart or Procedure Chart.
System Flowchart Symbols

(i) Manual Input: It is used to enter data manually. For example, keyboard is a manual input device.

(ii) Process: All type of processes is denoted by Rectangle.

(iii) Magnetic Disk: Mass storage device (Hard Disk).

(iv) Magnetic Tape: Magnetic tape is also storage device.

(v) Display: This is a symbol for online display, Example: Monitor (VDU).

(vi) Document: The print out document is denoted by this symbol.

Program Flowchart and System Flowchart:

Sn. Program Flow Chart System Flow Chart


1. The pictorial presentation of program is System flowchart is a pictrorial
called Flowchart. It us a tool and technique representation of procedure flows inside and
to find out solution of programming outside of the systems. It is also called Data
problems through some special sysmbols. It Flow Chart or procedure Chart. The special
is a way to represent program using type of symbols is used to represent system
geometrical patterns. flowchart.
2. It is tool of programmers. The flowchart This is a flowchart to show data flow inside
designing to solve any problem is called or out to designed system. The system
program flowchart. The candidate system is designers draw it to show data flow inside
designed using program flowchart. the current system.
Problem-1: The source program is stored in hard disk and after compilation; the object program
(Machine code) is also stored in hard disk. The rectangle represents compilation process. The error
messages are printed out and displayed on VDU also.

Compilation Process

Problem-2: Draw a system flow chart to update master-file.

System Flowchart to update master file

Problem-3: The headquarter of ABC Private Ltd. is linked with production, marketing and sale
department. The day-by-day information of each department is compiled at headquarter, stored in master
file and report is given to higher authority of company.
2. Algorithm
Algorithm is a stepwise presentation of procedures of program in simple and phraseless English. It is
also a programming tools used by programmer to develop software. It is a logical representation of
program procedures in order to obtain result. So, sometimes, it is called Procedure also. An
algorithm, named after the ninth Centaury scholar Abu Jafar Muhammad Ibn Musa Al-Khowarizmi of
Bagdad (Iraq).

A program is an expression of an idea in any programming language. A programmer starts with a general
idea of a task for the computer to perform. The problem is flesh out the outline into a complete,
unambiguous, step-by-step procedure for carrying out the task. Such a procedure is called an
‖Algorithm―. An algorithm is not same as program. An algorithm is more like the idea behind the
program.

• Language independent
• Simple, complete, unambiguous, step-by-step program flow
• no standard format or syntax for the algorithm
• helpful to understand problems and plan out solution

Example: Following algorithm is written to find out roots of quadratic equations:

• Step-1: Start
• Step-2: Read a,b and c
• Step-3: d=b*b-4*a*c
• Step-4: if D<0, root is imaginary
• Step-5: x1 = (-b + sqrt (D))/(2*a)

X2=(-b-sqrt(D))/(2*a)

• Step-6: Display x1 and x2


• Step-7: Stop

Example: Write an algorithm to find out area of triangle when sides are given.

Algorithm:

Step-1: start

Step-2: read a,b and c

Step-3: S=(a+b+c)/2

Step-4: A=sqrt((s-a)(s-b)(s-c))

Step-5: Display A

Step-6: Stop

Example: Write an algorithm to find out slop and mid point of coordinate.

Algorithm:

Step-1: Start

Step-2: Read x1, x2, y1 and y2 Step-


3: Slop=(y2-y1)/(x2-x1) Step-4: x-
(x1+x2)/2
Step-5: y=(y1 + y2)/2

Step-6: Stop

There are no standard rule for algorithm designing, but we can use some common rules which are not
ambiguous to another computer literates:

(a) Value to variable: variable (Variable or Expression)

(b) Conditional statements: if -endif and if –else-end-if are used for conditions.
Example:

If age>=18 then print ―Case vote‖ Else


print ―Wait until not 18‖ Endif
(c) looping statements:

i. do while (condition)
Statement(s)
endo

ii. for variable=value1 to final value step stepvalue


statement(s)
endfor

Example: Write an algorithm to display factrolial of given number. Fact =


1
Print ―Enter number‖ Read
number
For count =1 to count number step 1 Fact =
fact * count
Endfor

Print ―Factorial:‖, fact End


Problem-1: Draw a flow chart to input two numbers and display sum.

Flow Chart to display sum of two numbers

Problem-2: Draw a flowchart to enter principal,rate and time and display simple interest.

Flowchart to Calculate Simple Interest


Problem-3: Draw a flowchart to find the sum of the given series.

Solution,

Flow Chart to find sum of series

3. Pseudo-code or Structured English


A logical construction, which has

(a) No strict rules like as programming language,

(b) Unambiguous statements,

(c) Phrase less statements, contains noun and simple verb of English , and

(d) No adjective and adverbs structure is called Pseudo-code or Structured English.


It is a Program Design Language (PDL) provides skeleton for program design and it can replace
flowchart used to describe system design.

General rules used in writing Pseudo-codes are as follow:

(i) Imperative Sentence: The imperative sentences are used to show actions.

Example: Add x to sum, Display result, Sort list etc.

(ii) Operators: Mostly arithmetic operators (+, -, *, / etc) and relational operators (=, =>, =>, <,
> etc.) are used.

(iii) Decision: IF, THEN, ELSE, ENDIF, CASE, ENDCASE are used for decision-making.

Example:

CASE (choice)

(Choice = 1):Display Employee, Department

(Choice = 2): Display Employee, BasicSal, Allowance, Gross (Choice = 3):


Terminate Program
ENDCASE.

(iv) Looping: The looping or repetition of statements is shown by FOR, FOR DO, ENDFOR, DO,
DO WHILE, DO UNTIL, ENDDO etc.

Example:

Display ―Selected for National scholarship Examination‖ FOR roll1


TO roll=10 DO
Display roll, Name, Address

ENDFOR.

Example:

IF age >=18

THEN CASTE vote

ELSE
WAIT until age is not 18

ENDIF

Example: Mailing a letter BEGIN


WRITE a letter

IF bicycle is available

THEN GO to Post Office by Bicycle ELSE


GO to Post Office on foot ENDIF
BUY a stamp

STICK a stamp on the letter PUT into


letterbox
END.

4. Decision Table
A decision table defines a logical procedure by means of a set of conditions and related actions. It is
used for communicating and documenting complex decision procedures.

Procedure: The decision table is divided into four quadrants: Condition stub, Condition entry, Action
stub, and action entry. The conditions are answered as Y (yes) or N (No). The blank space shows that
the condition involved has not been tested. X (or check marks) represents response to the answer.
Condition Stub C1 R1 R2 R3 R4

C2 Condition entry

Cn
Action Stub A1 Action entry

A2

An

Problem: The policy followed by an ABC Ltd. to process agents‘ orders is given by the following
rules:

(i) If the customer order <= that in stock and his credit is OK, supply his requirement.

(ii) If the customer credit is not OK, do not supply. Send him intimation.

(iii) If the customer credit is OK but items in stock are less than his order, supply what is in stock.
Enter the balance to be sent in a back-order file.

Decision Table:

Order <=Stock Y Y N N
y N Y N
Credit OK
A1: Supply order X - - -
-
A2: Credit not OK - X
- X
Pay cash
-
A3: Supply Stock - - - -

A4: Enter (order-


Stock) in back - - -
order file

Problem: Create a decision table to decide whether on a given data a student in an University has
completed 3 years of enrolment or not.

Decision Table:

Let data enrolment Dj – Mj – Yj (day-month-year) and current date is Dt – Mt – yt (say – Month –Year)

If (Yj – Yt) >3 =3 =3 Else

If (Mj – Mt) - >0 =0

If (Dj – Dt) - - >=0


3 years enrolment? Y Y Y N

Problem: The Delta gas company bills its customers according to the following rate schedule:

(i) First 500liters Rs. 50 (flat)

(ii) Next 300 Liters Rs. 5.25 per 100 liter

(iii) Next 30,000 liters Rs. 2.50 per 100 liters

(iv) Above this Rs.2.00 per 100 liters.

The input record has customer identification, name and address, new meter reading, past and present.
Create decision table to obtain bill for customers.

Decision Table:

Consumption= old meter reading-new meter reading


Charge table:

Consumption <=500 501 to 800 801 to 30800 >30801

Go To C1 C2 C3 C4

C1: Charge=50

C2: Charge=50+ (consumption-500)*0.0525 C3:


Charge=65.75+ (consumption-800)*0.0250
C4: Charge=815.75+ (consumption-30800)*0.02

Problem. A bank has the following policy on deposits: on deposits of Rs. 25000 and above and for
three years or above the interest is 10%. On the same deposit for a period less than three years it is 8%.
On deposits below Rs. 25000 the interest is 6% regardless of the period of deposit.
Write the above process using

(a) Structural English

(b) A decision Table.

Solution

(a) for each deposit do If


deposit>=25000 Then if
period>=3 years Then
interest=10%
Else interest=8% Endif
Else interest 6% Endfor
(b) Decision table:

Deposit>=25000 Y Y N

Y N -
Interest % 10 8 6

5. Decision Tree
The tree like presentation of condition and actions are called decision tree. Every node denotes
conditions. It is used for logical variations and problems involving few complex decisions with complex
branching routines.

Example: The person which age is greater or equal to 18 can caste vote in the favour of his leader
otherwise has to wait until age of 18. There is two conditions (a)age<18, and (b)age>=18, both the
conditions have actions.

Decision Tree

Example: The hotel ABC offers new discount scheme foe university students. It provides 15% and
10% discount to monthly customers for vegetarian and non-vegetarian meal respectively. The student
attend hotel occasionally have discount rate 10% and 5% for vegetarian and non- vegetarian meal.
Draw decision tree to show discount scheme:

Example of Decision tree

You might also like