Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
14 views

SP Topic 1 - Introduction To SP

Uploaded by

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

SP Topic 1 - Introduction To SP

Uploaded by

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

STRUCTURED PROGRAMMING

TOPIC 1: INTRODUCTION
INTRODUCTION TO STRUCTURED PROGRAMMING
Computer hardware - the physical components and devices that make up a computer system.
These components are:
a. Input devices – they are used to enter data and instructions into the computer system before any
computation begins.
• Examples: keyboard, mouse, scanner

b. Storage unit – used to store data and instructions entered into a computer system as well as all
intermediate and end results before being passed to an output unit.
It is divided into 2:
• Primary storage
• Secondary storage

c. Central Processing Unit – This is the brain of the computer. It makes all major decisions,
calculations and comparisons. It also directs (i.e., activates and controls the operation of) other parts
of the computer system.

d. Output devices – they provide data and/or information to a computer user. This data and/or
information is produced by the computer in coded (machine readable) form, converted into human
readable form and then displayed to the computer user.
• Examples: monitors, printers, projectors
Computer software - a collection of programs, data, and instructions that control the operation and
functionality of a computer system.
It is divided into 2:
a. System software – Programs that act as an interface between the hardware of the computer and the
application software.
• Example: Operating system (OS), device drivers

b. Application software - Programs designed to perform specific tasks or provide specific functionality
to users.
It is the type of software that users interact with directly to accomplish various purposes, such as
productivity, entertainment, or communication.
• Example: Word processing software, Web browsers, Multimedia software
Data - collection of raw facts and figures that can be processed to gain information or insight.
It can be represented in various formats, including numbers, text, images, audio, video, or any other form
that can be stored and manipulated by computers.
Information - Processed or organized data that has been interpreted or given context to make it meaningful
and useful.
It is the result of analyzing, categorizing, and presenting data in a way that can be understood and applied by
individuals or systems.
Programming - the process of writing sets of instructions, known as code, that instruct a computer on how
to perform specific tasks.
Program - a set of instructions written in a programming language that is designed to be executed by a
computer.
Structured programming - a method of writing code that emphasizes the use of control flow constructs to
improve the clarity, readability, and maintainability of software code.
It promotes the idea of breaking down programs into smaller, manageable units called modules which
perform specific tasks.
These modules are then combined to form the overall program.
Importance of structured programming
1. It reduces the complexity of programs.
2. Enhances code readability, making it easier to understand and modify.
3. It promotes modularization and code reuse.
4. It promotes writing code that is less prone to errors.

EXAMPLES OF STRUCTURED PROGRAMMING LANGUAGES


• PASCAL
• C
• ADA
• JAVA
• PYTHON

HISTORY OF PROGRAMMING LANGUAGES


The history of programming languages dates back to the early days of computing. Here's a brief overview:
A. LOW-LEVEL LANGUAGES – Programming languages directly understood by the computer.
1. Machine Language (1940s-1950s): The earliest programming languages were machine languages,
consisting of binary instructions (1s and 0s) that directly operated on the hardware. Programming in
machine language required a deep understanding of the computer's architecture and was highly error-
prone.
2. Assembly Language (1950s-1960s): Assembly languages were developed as a symbolic
representation of machine language instructions. They used alpha-numeric symbols called
mnemonics to represent instructions and operands, making programming slightly more accessible.
Assembly languages were specific to each computer architecture.
B. HIGH-LEVEL LANGUAGES – Programming languages containing English words and symbols.
Examples of high-level languages:
3. Fortran (1957): (short for "Formula Translation") was the first high-level programming language.
Fortran was primarily used for scientific and engineering calculations.
4. LISP (1958): (short for "LISt Processing") was the first programming language focused on symbolic
processing and artificial intelligence.
5. COBOL (1959): (short for "COmmon Business-Oriented Language") was designed for business
applications for handling common business tasks. COBOL is still in use today in legacy systems.
6. BASIC (1964): Beginner's All-purpose Symbolic Instruction Code (BASIC) was developed to make
programming more accessible to non-specialists. It had a simple syntax and was widely used in
educational settings.
7. C (1972): Developed by Dennis Ritchie at Bell Labs, C became immensely popular due to its
efficiency and portability. It introduced structured programming concepts, such as functions and
control structures, and influenced the design of many subsequent languages.
8. Pascal (1970): was designed as a teaching language. It emphasized readability and structured
programming. Pascal had strong typing and introduced features like records and sets.
9. C++ (1983): It was developed as an extension of the C language, adding object-oriented
programming features. C++ combined the efficiency of C with the flexibility of object-oriented
programming and became widely used for application and system development.
10. Java (1995): This language aimed to be platform-independent. It introduced the concept of "write
once, run anywhere" by using a virtual machine to execute code. Java gained popularity for web and
enterprise applications.
11. Python (1991): This focused on code readability and simplicity. It gained popularity due to its ease of
use, versatility, and large standard library. Python is now widely used in various domains, including
web development, data science, and artificial intelligence.
C. FOURTH GENERATION LANGUAGES
Fourth-generation languages (4GLs) are programming languages that are designed to provide a higher level
of abstraction and productivity compared to lower-level languages like assembly or even high-level
languages.
They are often used for database-oriented applications and focus on simplifying the process of developing
software by providing powerful built-in features and utilities.
Examples of 4GLs include SQL (Structured Query Language), which is commonly used for database
querying and manipulation. These languages and tools provide developers with the ability to quickly build
database applications with minimal coding effort, leveraging the power of database management systems
and reducing the need for low-level programming tasks.
D. FIFTH GENERATION LANGUAGES
These languages are designed to facilitate high-level problem-solving, natural language understanding, and
advanced artificial intelligence capabilities.
Overall, the goal of 5GLs is to provide developers with powerful abstractions, natural language capabilities,
and AI integration to further enhance productivity, problem-solving, and the development of intelligent
applications.

These are just a few examples from the vast landscape of programming languages. Over time, countless
languages have been developed, each with its own strengths and purposes, catering to different application
domains and programming paradigms.

PROGRAMMING PARADIGMS
Programming paradigms are different approaches or styles of programming that provide a set of principles,
concepts, and techniques for designing and building computer programs. These paradigms dictate how
programmers structure and organize their code, how they solve problems, and how they think about
programming.
Here are some commonly recognized programming paradigms:
1. Unstructured programming - programming paradigm characterized by a lack of systematic
organization and control structures. In this paradigm, program flow is typically based on the use of
"go to" statements, allowing the execution to jump between arbitrary points in the code.
Demerits of unstructured programming
a. Unstructured programming can result in spaghetti code, which is difficult to read, understand,
and maintain.
b. It lacks clear structure and can lead to code duplication, poor code reuse, and increased
complexity.
Unstructured programming is generally considered outdated and has been largely superseded by more
structured and disciplined programming paradigms.

2. Structured programming - programming paradigm that emphasizes the use of well-defined


structures and control flow constructs to enhance code clarity, maintainability, and readability.
Structured programming avoids the use of "go to" statements and instead relies on control structures
like loops, conditionals, and subroutines to guide program execution.
Merits of structured programming
a. It promotes the use of modularization through procedures or functions, allowing for code reuse
and better organization.
b. By breaking down complex problems into smaller, manageable units, structured programming
facilitates easier debugging, testing, and maintenance of code, leading to more reliable and
efficient programs.

3. Object-oriented programming (OOP) - programming paradigm that revolves around the concept
of objects, which are instances of classes.
OOP allows for the modeling of real-world entities as objects with properties (attributes) and
behaviors (methods), enabling a more intuitive representation of the problem domain.
OOP facilitates the development of modular, maintainable, and scalable software systems by
providing a structured approach to designing and interacting with code.

4. Visual programming - programming paradigm that focuses on creating programs by visually


manipulating graphical elements or symbols instead of writing code in a traditional text-based
format.
This paradigm abstracts away the complexity of syntax and programming language details, making it
accessible to non-programmers and enabling rapid prototyping and development.
Visual programming is often used in areas such as graphical user interface (GUI) development, game
design, and data visualization, where the visual representation of the program's logic is critical.

5. Internet-based programming, also known as web programming - programming paradigm centered


around creating applications that run on the internet and utilize web technologies.
Web programming involves designing and developing websites, web applications, and web services
that can be accessed and utilized over the internet.
Web programming is essential for building e-commerce platforms, social media applications, online
services, and a wide range of web-based solutions that power the modern internet.

COMPUTER HARDWARE AND SOFTWARE CONSIDERATION FOR STRUCTURED


PROGRAMMING
Hardware considerations
When considering computer hardware for structured programming, there are a few key factors to keep in
mind:
1. Processing Power: Structured programming typically involves executing complex algorithms and
performing computations. Therefore, having a processor with sufficient speed and processing power
is essential for efficient program execution.
2. Memory (RAM): Structured programming often involves working with large amounts of data, and
having sufficient memory is crucial for storing and manipulating that data efficiently. Ensure that
your computer has enough RAM to accommodate the size of the data sets your programs will handle.
3. Storage: While structured programming primarily focuses on program logic and control flow, the
choice of storage can still impact performance.
4. Input/Output Devices: The choice of I/O devices is generally independent of the programming
paradigm. However, ensure that these devices are reliable and suitable for your programming needs,
as they directly impact your productivity and comfort while coding.
5. Development Tools: When practicing structured programming, using an integrated development
environment (IDE) that supports features like code navigation, syntax highlighting, and debugging
can greatly enhance the programming experience. Choose an IDE that is compatible with your
hardware and offers the necessary features to support structured programming practices effectively.
Ultimately, while structured programming does not impose specific hardware requirements, having a well-
configured and capable computer system will contribute to a smooth and efficient development experience.
Software considerations
When considering computer software for structured programming, here are some key considerations:
1. Programming Language: Select a programming language that supports structured programming
constructs effectively. Most modern programming languages, such as C, C++, Java, Python, and C#,
provide support for structured programming through features like functions, conditionals, loops, and
modularization. Choose a language that best aligns with your project requirements and familiarity.
2. Integrated Development Environment (IDE): An IDE tailored for structured programming can
significantly enhance productivity. Look for an IDE that provides features like code navigation,
syntax highlighting, and debugging capabilities. The IDE should also integrate well with the chosen
programming language.
3. Version Control System: Version control is crucial for managing source code, especially when
working on larger projects or collaborating with a team. Utilize a version control system to track
changes, enable collaboration, and facilitate code management. Choose a version control system that
integrates well with your preferred IDE and supports structured programming workflows.
4. Code Documentation and Testing Tools: Structured programming emphasizes code clarity and
maintainability. Utilize code documentation tools to generate documentation from inline comments.
Additionally, incorporate unit testing frameworks to ensure the correctness and robustness of your
code.
5. Libraries and Frameworks: Depending on your project requirements, one can use existing libraries
and frameworks that align with structured programming principles. These libraries can provide pre-
built modules and components, saving development time and effort. Ensure compatibility with your
chosen programming language and evaluate the suitability of libraries for your specific needs.
6. Performance Profiling and Debugging Tools: These help identify bottlenecks and optimize code
execution. Profilers assist in analyzing code performance. Similarly, debugging tools can aid in
identifying and resolving issues during development.
7. Documentation and Learning Resources: Availability of comprehensive documentation, tutorials,
and learning resources for your chosen programming language and related tools is crucial. Robust
online communities, forums, and official documentation can provide valuable insights,
troubleshooting assistance, and best practices.
By considering these software aspects, you can create a conducive environment for structured programming,
enabling efficient development, code maintenance, and collaboration.

PROGRAMMING LANGUAGE TRANSLATORS


Assembly programming language and High-level programming languages contain English words and
phrases.
In order for these languages to be understood by a computer, they need to be translated or interpreted into
machine-readable format.
Tools used to achieve this include:
1. Assembler – Software that reads a program written in assembly language and translates it into an
equivalent program in machine language.
2. Compiler – software that reads a program written in high level language and translates it into an
equivalent program in machine language.
3. Interpreter – also reads a program written in high level language and translates it into an equivalent
program in machine language.
However, a compiler converts the entire source code into machine-level program while the
interpreter translates the code one line at a time.
4. Linker – software that takes one or more object files generated by a compiler and combines then
into a single executable file, library file or another object file.
ASSIGNMENT:
1. Differentiate between primary and secondary storage in a computer system.
2. Outline the advantages and disadvantages of:
a. Low-level programming languages
b. High-level programming languages
3. Outline differences between a compiler and an interpreter

You might also like