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

GET 211 - Lecture Material-Ogu-2

The document discusses essential software programming techniques, focusing on the Top-Down and Bottom-Up approaches, and their application in modern methodologies like Agile and DevOps. It covers structured programming principles, object-oriented programming concepts, and various data structures, emphasizing their importance in software development. Additionally, it provides examples of syntax in different programming languages and highlights the necessity for students to learn at least one programming language.

Uploaded by

possibled123
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)
10 views

GET 211 - Lecture Material-Ogu-2

The document discusses essential software programming techniques, focusing on the Top-Down and Bottom-Up approaches, and their application in modern methodologies like Agile and DevOps. It covers structured programming principles, object-oriented programming concepts, and various data structures, emphasizing their importance in software development. Additionally, it provides examples of syntax in different programming languages and highlights the necessity for students to learn at least one programming language.

Uploaded by

possibled123
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/ 23

GET 211:

Computing and
Software
Engineering
(Programming Concepts)

Reginald Ekene Ogu


[email protected]
Software Programming
Techniques

Software programming techniques are essential methods and


strategies used to develop software applications.

Two widely recognized approaches are the Top-Down Approach


and the Bottom-Up Approach.

These techniques are complementary and often combined in


modern software development methodologies like Agile and
DevOps, enabling flexibility and efficiency in project management.
Comparison Between Top-Down and Bottom-
Up Approaches

Aspect Top-Down Bottom-Up


Starting Point High-level design Low-level components
Focus Breaking down the system Building and integrating components
Reusability Less focus on reuse Strong emphasis on reusable modules

Debugging Debugging is modular Debugging may involve integration issues

Integration Modules are integrated systematically Integration is iterative and incremental


Structured Programming

• A programming paradigm aimed at improving code clarity, reliability, and efficiency.


• It uses a top-down approach with well-defined control structures.
• Promotes modularity, making programs easier to understand and maintain.
Key Principles of Structured Programming
1. Sequence – Execution flows in a linear and logical order.
2. Selection – Decision-making through conditional statements (e.g., if-else).
3. Iteration – Looping mechanisms for repetitive tasks (e.g., for, while loops).
Benefits of Structured Programming

• Improves Readability – Well-organized code is easier to understand and debug.

• Enhances Maintainability – Modular code can be modified without affecting the entire program.

• Reduces Complexity – Breaks down a program into manageable sections.

• Promotes Reusability – Functions and modules can be reused across different programs.

Commonly Used Languages

• C
• Pascal

• Python

• Java
Key Constructs of Structured Programming

Control Structures
1. Sequential Execution
o Statements are executed one after the other in a logical order.
2. Decision Making (Selection)
o if-else, switch-case statements for conditional execution.
3. Loops (Iteration)
o for, while, do-while loops for repetitive tasks.
4. Functions & Procedures
o Encapsulate code into reusable blocks to improve modularity.
Structured Programming Approach Using C
• Symbols: Special characters ({}, • Statements
;, ++). ➢ Assignment: a = 5;
• Keywords: Reserved words (int,
➢ Conditional: if, else.
if, return).
• Identifiers: Names for variables, ➢ Looping: for, while.
constants, functions. • Operator Precedence:
• Data Types: ➢Parentheses ()
o Primitive: int, float, char. ➢Multiplication *, Division /
o Composite: Arrays, ➢Addition +, Subtraction -
structures.
• Operators: Arithmetic (+, -), ➢Relational >, <=
Logical (&&, ||), Relational (<, >=). ➢Logical AND &&, OR ||
C programming: Example
• Example Code: Factorial in C
• Functions: Reusable code blocks.
#include<stdio.h>
• Recursive Functions: Example:
int main() {
int factorial(int n) {
int n, factorial = 1;
if (n == 0) return 1;
printf("Enter a number: ");
return n * factorial(n-1);
scanf("%d", &n); }
for (int i = 1; i <= n; i++) {
factorial *= i;
}
printf("Factorial: %d\n", factorial);
return 0;
}
Object-Oriented Programming

• OOP is a programming paradigm based on the concept of objects, which contain data (attributes)
and methods (functions).

• It enables modularity, reusability, and maintainability in software development.

• Examples of OOP languages:


1. Python,
2. Java,
3. C++,
4. C#,
5. Ruby.
Key Principles of OOP

1. Encapsulation – Bundling data and methods within an object to restrict direct access.

2. Abstraction – Hiding complex implementation details and exposing only the necessary parts.

3. Inheritance – Creating new classes from existing ones to promote code reuse.

4. Polymorphism – Allowing objects to be treated as instances of their parent class for flexibility.

Advantages of OOP
Code Reusability – Inheritance reduces code duplication.
Modularity – Objects can be developed independently and integrated later.
Scalability – Large applications are easier to manage.
Security – Encapsulation restricts direct access to sensitive data.
Real-World Applications of OOP

01 02 03 04 05
Web Game Embedded AI & Machine Enterprise
Development Development Systems (e.g., Learning (e.g., Applications
(e.g., Django, (e.g., Unity, Arduino, TensorFlow, (e.g., ERP &
Spring Boot) Unreal Engine) Raspberry Pi) PyTorch) CRM software)
Differences of Terms of OOP

Feature Class Attribute Method


A variable storing object A function performing an
Definition A blueprint for objects
data action
Defines structure & Represents object
Purpose Represents object state
behavior behavior
Example Car self.brand = "Toyota" start_engine()
Contains? Attributes and methods Data Code logic
Syntax in Programming

In programming, syntax
Each programming language
refers to the set of rules and
has its own syntax rules.
structure that define how
Writing code incorrectly
code must be written to be
(syntax errors) will prevent it
understood and executed by
from running properly.
a compiler or interpreter.
1. Python Syntax (Simple and Readable)

# Python syntax example


def greet(name):
print(f"Hello, {name}!")

greet("Alice")
Uses indentation for blocks
No need for semicolons
2. C++ Syntax (Uses Curly Braces & Semicolons)

#include <iostream>

using namespace std;

void greet(string name) {

cout << "Hello, " << name << "!" << endl;

int main() {

greet("Alice");

return 0;

Uses {} for function blocks


Ends statements with ;
3. Java Syntax (Object-Oriented & Strict Type
System)

class Main {
public static void main(String[] args) {
System.out.println("Hello, Alice!");
}
}
Uses class and main function
System.out.println for output
Common Syntax Elements in Programming

Syntax Element Description Example (Python)

Keywords Reserved words for specific actions def, if, while, return

Variables Store values name = "Alice"

Operators Perform operations on data x=5+3

Functions Block of reusable code def greet(): ...

Control Structures Direct program flow if, for, while

Comments Notes ignored by the compiler # This is a comment


Data Structures in Programming
A data structure is a way of organizing, storing, and managing data efficiently for performing operations such as
searching, sorting, and modifying data.

Types of Data Structures:

Data structures can be classified into two main types:

1. Primitive Data Structures

These are the basic building blocks of data storage:

• Integer (int) – Stores whole numbers (e.g., 5, 100).

• Float (float) – Stores decimal numbers (e.g., 3.14, 2.5).

• Character (char) – Stores a single character (e.g., 'A').

• Boolean (bool) – Stores True or False.


2. Non-Primitive Data Structures
These are more advanced structures that store multiple values.

A. Linear Data Structures

Data is arranged sequentially.

1. Arrays

o Fixed-size collection of elements of the same type.

o Example (Python):

o numbers = [10, 20, 30, 40]

o print(numbers[0]) # Output: 10

2. Lists (Dynamic Arrays in Python)

o Flexible and resizable.

o Example:

o my_list = [1, "Hello", 3.5]

o my_list.append(4) # Adds 4 to the list


A. Linear Data Structures Contd.

1. Stacks (LIFO - Last In, First Out)


o Uses push (add) and pop (remove).
o Example:
o stack = []
o stack.append(10) # Push
o stack.append(20)
o print(stack.pop()) # Output: 20 (Last in, first out)
2. Queues (FIFO - First In, First Out)
o Uses enqueue (add) and dequeue (remove).
o Example using collections.deque:
o from collections import deque
o queue = deque([1, 2, 3])
o queue.append(4) # Enqueue
print(queue.popleft()) # Output: 1 (First in, first out)
B. Non-Linear Data Structures
Data is stored in a hierarchical or interconnected way.

1. Trees (Hierarchical Structure): Used in databases, file systems, and AI.

o Example (Binary Tree in Python):


o class Node:
o def __init__(self, value):
o self.value = value
o self.left = None
o self.right = None
o
o root = Node(10)
o root.left = Node(5)
o root.right = Node(15)

2. Graphs (Nodes & Edges): Used in social networks, maps, and recommendation systems.
o Example (Graph Representation using Dictionary):
o graph = {
o 'A': ['B', 'C'],
o 'B': ['A', 'D'],
o 'C': ['A', 'D'],
o 'D': ['B', 'C']
o }
o print(graph['A']) # Output: ['B', 'C']
Comparison of Data Structures

Data Structure Type Usage


Array Linear Storing fixed-size data
List Linear Dynamic-sized collection
Stack Linear Backtracking, Undo-Redo
Queue Linear Scheduling, BFS Algorithm
Tree Non-Linear File systems, XML Parsing
Graph Non-Linear Social networks, AI
The End>>>
• Every student is expected to learn at least one programming language.

You might also like