0% found this document useful (0 votes)
41 views7 pages

SP Topic 2 - Prog DVLPMNT & Design

Uploaded by

denisnzyoka14
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)
41 views7 pages

SP Topic 2 - Prog DVLPMNT & Design

Uploaded by

denisnzyoka14
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/ 7

STRUCTURED PROGRAMMING

TOPIC 2: PROGRAM DEVELOPMENT AND DESIGN

PROGRAM DEVELOPMENT AND DESIGN


Program development and design in structured programming is an approach to software development that
emphasizes modular and organized code structures. It aims to improve code readability, maintainability, and
efficiency by breaking down a program into smaller, more manageable parts called modules or functions.
Structured programming gained popularity in the 1970s as a response to the complexity and difficulty in
maintaining large-scale software projects. It was a departure from earlier programming paradigms that relied
heavily on goto statements and unstructured control flow, which made programs hard to understand and
modify.
The key principles of structured programming are:
1. Top-Down Design: The program is divided into smaller, self-contained modules that are easier to
understand and implement. The high-level design of the program is created first, and then each
module is further decomposed until the individual functions or procedures are defined.
2. Modularity: Modules are designed to perform specific tasks or functions. They are independent and
can be reused in different parts of the program or in other projects. Each module should have a clear
purpose and well-defined inputs and outputs.
3. Structured Control Flow: The control flow within a program should be structured and easy to
follow. Structured programming makes use of control structures like loops (for, while) and decision-
making structures (if-else, switch) to provide clear and predictable control flow. This eliminates the
need for the infamous goto statement, which often led to spaghetti code.
4. Single Entry, Single Exit: Each module or function should have a single-entry point and a single
exit point. This helps in understanding and debugging the program flow, as well as ensuring that
resources are properly managed and released.
5. Data Abstraction: Structured programming promotes the use of data abstraction by defining abstract
data types (ADTs) that encapsulate data and operations on that data. ADTs provide a clear interface
to manipulate the data, hiding the internal implementation details.
By adhering to these principles, structured programming facilitates the development of reliable,
maintainable, and efficient software. It allows developers to understand the program's logic more easily,
makes it easier to identify and fix bugs, and supports code reusability.
Programming languages like C, Pascal, and Ada were specifically designed with structured programming in
mind. However, the principles and concepts of structured programming are applicable to various
programming languages and paradigms, including object-oriented programming (OOP).

PROGRAM DEVELOPMENT CYCLE


This is the process of creating a software. It is divided into:
1. Problem recognition – the process of identifying the problem that the program is going to solve.
2. Problem definition/analysis – programmer tries to determine the likely input, the processing
activities and the expected output.
3. Program design – process of developing algorithms based on the input, processing instructions &
the output identified in stage 2 using tools like flowcharts & pseudocodes.
4. Program coding – process of translating the algorithm into the equivalent program i.e., typing a
program using a particular programming language.
5. Program testing & debugging – testing is checking or ascertaining whether the program is working
as intended & performs the expected functions accurately.
Debugging is the process of detecting & correcting errors that may exist in a program.
Types of errors
a) Syntax errors – errors that occur due to improper use of language rules e.g. grammar
mistakes, improper naming of variables, etc.
b) Logical errors – errors that are not detectable by the compiler that make a program to run but
gives the wrong results (they occur when a program doesn’t perform its assigned duties as
expected.)
c) Run-time errors – errors that make a program to stop executing abruptly e.g. dividing a
number by zero
Methods of error detection & correction
a) Dry-running / desk checking – it involves going through the program while still on paper
before entering it or keying it into the program editor window.
b) Using debugging utilities – these are written software in the machine that evaluates a
program to identify various syntax errors
c) Using test data – involves carrying out trial runs on the new program by entering data
variations & extremes to test whether the system will halt.
Types of test data
a. Normal data – test data that is typical (expected) and should be accepted by the
system.
b. Extreme data – test data at the upper or lower limits of expectations that should be
accepted by the system.
c. Boundary data – a pair of values at each end of the range. i.e
i. The data at the upper or lower limits of expectations that should be accepted.
ii. The immediate values before or beyond the limits of expectations that should
be rejected.
d. Abnormal data / erroneous data – test data that falls outside of what is acceptable
and should be rejected by the system.
Test data example: For a program that only accepts numbers between 1 and
10, the test data could be:
Normal data – 5
Boundary data – 1,10 (to be accepted); 0,11 (to be rejected)
Extreme data – 1,10
Abnormal data – thirteen, 5.7, 14
6. Program implementation – actual delivery & installation of a new program ready to use. It involves
training of new users on how to use the program.
7. Review & maintenance – this takes place during & after implementation. It entails debugging errors
that occur while running the program or making any other revisions that may arise due to change of
user needs.
NB: DOCUMENTATION – the process of writing a formal support material explaining how a process
was developed, how it can be used, how it can be installed & how it can be modified by other
programmers.
Types of documentation – photocopied notes

STRUCTURED PROGRAMMING CONCEPTS


1. Top-down design
Top-down design is a design concept in structured programming that emphasizes breaking down a
problem or system into smaller, more manageable components or modules. It follows a hierarchical
approach, where the overall problem is divided into sub-problems, which are further divided into
smaller sub-problems, until the smallest components are reached. This process continues until the
problem is decomposed into its most basic and easily solvable parts.

In top-down design, the design process starts with the high-level or broad view of the problem. The
main task is to identify the major functionalities or modules required to solve the problem. These
major modules are then further divided into sub-modules, and this decomposition continues until the
lowest level of detail is reached.

The key steps involved in the top-down design process are as follows:

a. Problem Analysis: The first step is to understand and analyze the problem or system
requirements. This involves gathering information about the problem domain, identifying the
major functionalities, and determining the inputs, outputs, and processing requirements.

b. Identify Main Modules: Based on the problem analysis, the main modules or components
that are required to solve the problem are identified. These modules represent the major steps
or tasks involved in solving the problem.

c. Decomposition: Each main module is further decomposed into smaller sub-modules. The
decomposition is done by identifying the tasks or operations that need to be performed within
each module. This process continues until the modules are small enough to be easily
implemented.

d. Define Interfaces: Interfaces between the modules are defined, specifying how they will
communicate and interact with each other. This includes identifying the data inputs and
outputs for each module and defining the parameters and return values of functions or
procedures.

e. Implementation: The modules are implemented in the programming language of choice,


following the structure and logic defined during the design phase. Each module is
implemented independently, focusing on solving a specific sub-problem.
f. Integration: Once the individual modules are implemented, they are integrated together to
form the complete program. The interfaces between the modules are connected, ensuring
proper data flow and communication.

Benefits of top-down design:


a. It helps in managing the complexity of a problem by breaking it down into smaller, more
manageable parts to allow for easier understanding, testing, and maintenance of the code.
b. It promotes code reusability, as the modular structure facilitates the reuse of modules in
different programs or projects.
Overall, top-down design is a structured programming design concept that supports the systematic
decomposition of a problem, leading to a more organized and efficient software development
process.

2. Bottom-up design
This involves building a system or program from its individual components or modules. Unlike top-down
design, which starts with a high-level view and breaks the problem down into smaller parts, bottom-up
design begins with the smallest components and gradually assembles them into larger modules and
eventually the complete system.
In bottom-up design, the focus is on developing the individual building blocks first, and then combining
them to create more complex modules and eventually the entire system. This approach allows for greater
attention to detail at the lower levels and ensures that each component is functioning correctly before
integration.
The key steps involved in the bottom-up design process are as follows:
a. Identify Basic Components: The first step is to identify the basic components or modules required
to solve the problem. These components are usually the smallest and simplest parts of the system.
b. Implement Basic Components: Each basic component is implemented independently, focusing on
its functionality and correctness. This involves writing the code for each component, testing it, and
ensuring that it performs the desired operations correctly.
c. Test and Verify Components: Once the basic components are implemented, they are individually
tested to ensure that they work as expected. This includes verifying their behavior, handling edge
cases, and confirming that they meet the requirements.
d. Assemble Components: After the individual components have been tested and verified, they are
combined to create larger modules. These modules are built by integrating the basic components and
defining the interfaces between them.
e. Test and Verify Modules: The assembled modules are then tested to ensure that they function
correctly and produce the desired results. Integration testing is performed to verify the interactions
between the modules and to identify any potential issues or errors.
f. Repeat the Process: The process of implementing, testing, and integrating components and modules
is repeated, gradually moving from smaller modules to larger ones, until the complete system is built.
Bottom-up design allows for a more incremental and iterative development approach. It ensures that each
component is thoroughly tested and validated before moving on to the next level of integration. This
approach also promotes code reusability, as the independently developed and tested components can be
easily reused in different systems or projects.
Overall, bottom-up design is a structured programming design concept that focuses on developing and
integrating smaller components to build larger modules and systems. It ensures attention to detail,
encourages code reusability, and facilitates a systematic and incremental approach to software development.
3. Modular design
Modular design is a key design concept in structured programming that emphasizes dividing a program into
self-contained modules or units. Each module represents a distinct functionality or task and can be
developed and tested independently. These modules interact with each other through well-defined interfaces,
providing a way to organize and manage complex systems efficiently.
Here are the main aspects of modular design in structured programming:
a. Encapsulation: Modules in structured programming encapsulate a set of related operations or data.
They provide a logical boundary around a specific functionality, allowing for information hiding and
reducing the complexity of the overall system. Encapsulation ensures that the internal details of a
module are hidden from other modules, providing abstraction and making the system more
maintainable.
b. Cohesion: Modules should exhibit high cohesion, which means that the operations within a module
are closely related and focused on a single task. High cohesion promotes code clarity, reusability, and
maintainability. It allows modules to be easily understood and modified without affecting other parts
of the program.
c. Low Coupling: Coupling refers to the degree of interdependence between modules. In modular
design, it is desirable to have low coupling, which means that modules are loosely connected and
have minimal reliance on each other. Low coupling enhances the modifiability and reusability of
modules, as changes in one module are less likely to affect other modules.
d. Interface Design: Modules interact with each other through well-defined interfaces. The interface
defines the inputs, outputs, and functionalities that are exposed to other modules. A clear and
standardized interface facilitates communication and integration between modules and allows for
easy replacement or modification of modules without affecting the entire system.
e. Abstraction: Modular design promotes abstraction by hiding unnecessary implementation details
and exposing only the essential functionalities and data structures. This allows programmers to work
with higher-level concepts and simplifies the understanding and use of modules.
f. Information Hiding: Modules should hide their internal details and only expose the necessary
information to other modules. Information hiding helps to minimize dependencies and maintain the
integrity of the module's implementation. It also allows for future modifications or enhancements to
be made within the module without impacting other parts of the program.
g. Reusability: Modules designed with a modular approach are typically reusable. They can be easily
integrated into different systems or projects, reducing development time and effort. Reusable
modules enhance productivity and code maintainability.
By employing modular design principles, structured programming promotes code organization, readability,
reusability, and maintainability. It allows developers to tackle complex problems by breaking them down
into manageable components that can be independently developed, tested, and modified. Modular design
facilitates collaboration among team members, as different modules can be developed in parallel, and the
system can be built by integrating the modules together.
4. Control flow structure
This governs the order in which program statements are executed. It provides the means to control the flow
of execution based on certain conditions or rules, enabling the program to make decisions and repeat or skip
certain blocks of code. The control flow structures in structured programming include sequence, selection,
and iteration.
a. Sequence: Sequence is the simplest control flow structure, representing the default flow of execution
where statements are executed in the order they appear. The program follows a linear path, executing
one statement after another until it reaches the end. Sequence ensures that statements are executed
sequentially, allowing the program to perform a series of actions or operations.
b. Selection: Selection structures, such as "if-else" statements and "switch" statements, enable the
program to make decisions based on certain conditions. These structures allow the program to
selectively execute different blocks of code depending on the outcome of a condition evaluation.
i. "if-else" statement: It evaluates a condition and executes a specific block of code if the condition
is true. If the condition is false, an alternative block of code can be executed using the "else"
clause.
ii. "switch" statement: It evaluates an expression or variable and matches it against multiple cases.
The corresponding case block is executed based on the matching value.
Selection structures enable the program to take different paths or perform different actions based on
conditions, providing flexibility and decision-making capabilities.
c. Iteration: Iteration, also known as looping, allows the program to repeat a block of code multiple
times until a certain condition is met. Iteration structures provide a way to automate repetitive tasks
and perform actions on collections of data.
i. "for" loop: It executes a block of code a predetermined number of times, based on a control
variable that increments or decrements with each iteration.
ii."while" loop: It repeatedly executes a block of code as long as a condition remains true. The
condition is evaluated before each iteration.
iii."Do-while" loop: It executes a block of code at least once and then repeatedly executes it as long
as a condition remains true. The condition is evaluated after each iteration.
Iteration structures allow the program to efficiently process large amounts of data, implement algorithms,
and solve problems that require repetitive computations.
By using control flow structures effectively, structured programming enhances code readability,
maintainability, and understandability. It enables programmers to express complex logic in a structured and
organized manner, leading to efficient and reliable software.
5. Monolithic design
This refers to the design approach where a program is structured as a single, large module or codebase. In a
monolithic design, the entire program logic is contained within a single file or unit, and there is no clear
separation of functionalities.
Key characteristics of monolithic design in structured programming are as follows:
i. Lack of Modularization: Monolithic design does not follow the modular design principles of
structured programming. Instead of dividing the program into smaller, self-contained modules, all the
code resides in a single unit. This can lead to a large and unwieldy codebase, making it challenging
to understand, maintain, and modify the program.
ii. Tight Coupling: In monolithic design, different parts of the program are often tightly coupled with
each other. This means that changes made to one section of the code can have unintended
consequences on other sections. The lack of well-defined interfaces and encapsulation makes it
difficult to isolate and modify specific functionalities without affecting the entire program.
iii. Limited Reusability: Due to the lack of modularization, code reusability is limited in monolithic
design. Modules cannot be easily extracted and reused in other projects or systems. This can result in
code duplication and reduced development efficiency, as developers have to rewrite similar
functionalities for different parts of the program.
iv. Code Clutter: The absence of modularization in monolithic design can lead to code clutter. With all
the code in a single unit, it becomes harder to navigate, understand, and debug the program. It can
also make it challenging to collaborate with other developers or work on different parts of the
program concurrently.
v. Maintenance Challenges: Monolithic designs can pose challenges when it comes to maintaining
and evolving the program over time. Modifications or enhancements to specific functionalities
require understanding and potentially modifying a large portion of the code. This increases the
likelihood of introducing errors and makes it difficult to ensure code correctness and stability.
While monolithic design was commonly used in early software development practices, it is generally
considered less desirable in modern software engineering. The lack of modularity and the challenges
associated with monolithic designs have led to the adoption of modular design principles.
PROGRAM DESIGN TOOLS
In structured programming, there are several design tools and techniques that help in the process of program
design. These tools assist in visualizing the structure, flow, and organization of the program. Here are some
commonly used program design tools in structured programming:
1. Pseudocode: Pseudocode is a high-level, informal programming language that describes the
program's logic using plain language or a simplified syntax. It allows developers to express the
program's algorithmic steps without getting into the specifics of a particular programming language.
Pseudocode helps in clarifying the program's design and facilitates communication between
developers and stakeholders.
2. Flowcharts: Flowcharts are graphical representations of the program's logic and control flow. They
use symbols and arrows to represent different program components, such as inputs, outputs,
processes, decisions, and loops. Flowcharts provide a visual representation of the program's flow,
making it easier to understand and analyze.
3. Structure Charts: Structure charts illustrate the modular structure of a program by visually
representing the relationships between modules or functions. They show the hierarchy and
interconnections among different program modules, along with the flow of control and data between
them. Structure charts help in organizing and planning the program's structure and identifying
dependencies and relationships between modules.
4. Hierarchy Charts: Hierarchy charts depict the hierarchical structure of a program by representing
the modules or functions as boxes and showing the relationships between them. They illustrate the
program's structure in terms of levels or layers, with the main program at the top and the sub-
modules below. Hierarchy charts provide a clear overview of the program's structure and
organization.
5. Data Flow Diagrams (DFD): DFDs represent the flow of data within a system or program. They
illustrate how data moves through different processes, inputs, outputs, and data stores. DFDs help in
understanding the data requirements of a program and identifying the relationships and
transformations that occur within the program.
6. Structure Tables: Structure tables provide a tabular representation of the program's structure and
control flow. They outline the modules, inputs, outputs, and relationships between modules in a
structured manner. Structure tables are useful for documenting and planning the program's structure
and ensuring that all necessary components are accounted for.
These program design tools assist in the visual representation, organization, and planning of structured
programs. They help programmers and software designers in communicating ideas, analyzing program logic,
and ensuring a clear and well-structured design before moving on to the implementation phase.
NB: Emphasis on pseudocodes and flowcharts – photocopied notes
ASSIGNMENT:
1. Differentiate between syntax and semantics of a programming language.
2. In athletics track events, medals are awarded to the first 3 athletes. Position 1 gets a gold medal,
Position 2 gets a silver medal, and Position 3 gets a bronze medal.
a. Write a pseudocode to represent that
b. Draw a flowchart to represent that

You might also like