PROGRAMMING PRINCIPLES
Module 1: Apply Computer Programming Skills
1.1 Identification of Programming Languages
Key Definitions
Programming Language: A formal system of signs, syntax, and grammatical rules
used to construct instructions that a computer can interpret and execute.
Syntax: The structural rules governing the arrangement of words and symbols in a
programming language.
Semantics: The actual meaning, logic, and behavior of the code when executed.
Abstraction Level: The degree to which a programming language hides the
underlying hardware details from the developer.
1.1.1 Overview of Programming Language Categories
Procedural Programming
Executes a linear, top-down sequence of instructions called procedures, routines, or
subroutines.
Relies heavily on global variables and explicit state changes across functions.
Lacks built-in security features for data, making variables vulnerable to accidental
global modification.
Ideal for hardware control, drivers, and operating systems (e.g., C, COBOL, Fortran).
Object-Oriented Programming (OOP)
Groups data and behavior into single structural units called objects.
Structures applications using classes, which act as user-defined blueprints for
creating instances.
Enforces data security through encapsulation, hiding internal states from
unauthorized external access.
Simplifies software maintenance through code reuse, inheritance, and modularity
(e.g., Java, C++, Python).
Functional Programming
Models programs as a collection of mathematical functions that evaluate
expressions.
Prohibits changing states and mutable data to prevent unexpected code side effects.
Treats functions as "first-class citizens," meaning they can be assigned to variables,
passed as arguments, or returned from other functions.
Excels in parallel processing, concurrent computing, and big data analysis (e.g.,
Haskell, Scala, Lisp).
1.1.2 Criteria for Selecting Languages Based on User
Requirements
Platform Compatibility
Identifies whether the application must run on web browsers, desktop OS
environments, or mobile hardware.
Cross-platform languages reduce engineering costs by using a single codebase
across different target systems.
Native languages optimize device hardware usage but require separate codebases
and builds per platform.
Performance and Efficiency
Low-level compiled languages maximize CPU utilization and optimize manual
memory allocation.
High-level interpreted languages prioritize developer speed and safety over
execution efficiency.
Real-time systems require strict execution speed and deterministic garbage
collection routines.
Development Speed and Market Time
Determines how quickly a minimum viable product (MVP) can be launched to users.
Rich third-party libraries and pre-built frameworks drastically reduce total
development time.
High-level, expressive syntax lowers coding overhead and simplifies prototype
creation.
Team Expertise and Training Costs
Maximizes the existing technical skills and background of the available development
team.
Choosing unfamiliar languages increases project risk due to steep learning curves.
Minimizes onboarding time and costly training sessions for engineering staff.
Maintainability and Community Support
Long-term library stability ensures the software remains secure and operational over
years.
Large open-source communities provide rapid debugging assistance and extensive
documentation.
High code readability reduces future maintenance costs when onboarding new
developers to the project.
1.2 Application Programming Paradigms
Key Definitions
Paradigm: A fundamental style, model, or philosophical approach to writing
computer code and structuring software.
State: The stored configuration, variables, and data of a computer program at a
specific moment in time.
Mutability: The capability of an object or variable to have its value changed after it
has been created.
Immutability: The condition where a value or object cannot be modified after its
creation.
1.2.1 Common Programming Paradigms
[Link] Overview
A programming paradigm represents the architectural style used to design and
execute code.
Paradigms govern how developers view program execution, memory manipulation,
and logical organization.
[Link] Functional
Uses pure functions that always yield identical outputs for identical inputs,
completely eliminating side effects.
Employs immutable data structures to eliminate unexpected race conditions in multi-
threaded environments.
Replaces standard loops (for, while) with recursive function calls to manipulate
data structures.
[Link] Procedural
Isolates logical tasks into distinct blocks called subroutines, routines, or functions.
Manages execution flow through step-by-step algorithms and structural blocks.
Shares data globally across functions, which increases system coupling and tracking
complexity.
[Link] Object-Oriented (OOP)
Encapsulation: Binds code and data together within an object, restricting direct
external access to internal states.
Inheritance: Enables a child class to acquire the attributes and methods of an
existing parent class.
Polymorphism: Allows different objects to respond uniquely to identical method
calls (overriding and overloading).
Abstraction: Hides complex background implementation details, exposing only
essential operational interfaces.
[Link] Imperative
Focuses on detailing exactly how a machine must achieve a desired state through
step-by-step instructions.
Utilizes explicit commands, assignment statements, and conditional control flows.
Directly alters computer memory states during every consecutive step of program
execution.
[Link] Declarative
Focuses on describing what the final computation output should look like without
defining the step-by-step instructions.
Eliminates explicit instructions regarding execution flow, loop structures, and state
management.
Relies on an underlying engine to determine optimal execution paths (e.g., SQL,
HTML, CSS).
Paradigm Code Snippet Comparison
The following code snippets demonstrate how different paradigms solve the exact
same problem: doubling all even numbers in an array.
Procedural / Imperative Approach (Python)
python
# Procedural approach uses loops, indices, and step-by-step state
modifications
numbers = [1, 2, 3, 4, 5, 6]
doubled_evens = []
for i in range(len(numbers)):
if numbers[i] % 2 == 0:
doubled_value = numbers[i] * 2
doubled_evens.append(doubled_value)
print(doubled_evens) # Output: [4, 8, 12]
Use code with caution.
Object-Oriented Approach (Python)
python
# OOP approach uses classes, encapsulation, and object methods to
handle data
class NumberTransformer:
def __init__(self, data_list):
self.__data = data_list # Encapsulated private attribute
def process_evens(self):
result = []
for num in self.__data:
if num % 2 == 0:
[Link](num * 2)
return result
transformer = NumberTransformer([1, 2, 3, 4, 5, 6])
print(transformer.process_evens()) # Output: [4, 8, 12]
Use code with caution.
Functional / Declarative Approach (Python)
python
# Functional approach uses pure functions, immutability, and
declarative mapping
numbers = [1, 2, 3, 4, 5, 6]
# Using higher-order functions: filter() and map()
is_even = lambda x: x % 2 == 0
double = lambda x: x * 2
doubled_evens = list(map(double, filter(is_even, numbers)))
print(doubled_evens) # Output: [4, 8, 12]
Use code with caution.
1.2.2 Choosing the Appropriate Paradigm Based on Project
Needs
Web Scraping and Data Transformation: Select functional paradigms for error-free
mathematical calculations.
Embedded Firmware and Microcontrollers: Choose procedural paradigms for
precise, lightweight hardware control.
Enterprise ERP Software: Deploy object-oriented systems to mirror real-world
business domains and assets.
Database Management: Utilize declarative systems to extract data without
managing internal disk storage mechanics.
1.3 Program Development Life Cycle (PDLC)
Key Definitions
PDLC: A systematic framework outlining the distinct phases involved in building,
testing, and delivering software.
Functional Requirements: Specifications detailing what actions a software system
must perform (e.g., "process user payment").
Non-Functional Requirements: Specifications defining system quality attributes
(e.g., "page must load within 2 seconds").
Scope Creep: The uncontrolled, undocumented expansion of project requirements
without adjustment to time or budget.
1.3.1 Stages of the Program Development Life Cycle
1. Requirement Analysis
Business analysts gather clear, measurable functional and non-functional user
needs.
Defines the specific scope boundaries, budget limits, and hardware limitations of the
project.
Outlines specifications in a binding Software Requirement Specification (SRS)
document.
2. Design
Software engineers map system architecture, database schemas, and user interface
wireframes.
Creates precise Unified Modeling Language (UML) diagrams and entity-relationship
charts.
Identifies core software components, third-party API interactions, and network
security protocols.
3. Coding
Developers translate design models into working source code using appropriate
programming languages.
Adheres to strict internal coding standards, naming conventions, and style guides.
Utilizes version control software (e.g., Git) to manage parallel development and code
history tracking.
4. Testing
Quality assurance engineers execute test suites to locate bugs, syntax errors, and
logic flaws.
Combines automated tests (unit, integration) with manual exploratory testing
routines.
Ensures code fully satisfies all constraints and expectations established within the
SRS document.
5. Deployment
Ships the validated, stable software package into production cloud servers or client
local machines.
Configures production database connections, cloud infrastructure systems, and
security firewalls.
Provides user installation guides, operations manuals, and administrative training
materials.
6. Maintenance
Technical support staff monitors performance metrics, logs errors, and fixes reported
bugs.
Delivers software security patches to protect user data against emerging cyber
vulnerabilities.
Introduces system optimizations and software feature updates to meet evolving
business needs.
1.3.2 Best Practices for Adapting the Life Cycle to Work
Requirements
Waterfall Framework: Use for low-risk, predictable projects with completely frozen,
unchanging specifications.
Agile Framework: Deploy for fluid projects requiring rapid two-week product
iterations and constant customer feedback.
CI/CD Pipelines: Automate testing and deployment to reduce release cycle times
and minimize human error.
1.4 Application of Program Design Tools
Key Definitions
Algorithm: A finite, unambiguous set of sequential steps required to resolve an
exact computing challenge.
Pseudocode: A textual logic summary using structured language formats that mimic
actual code layouts without syntax rules.
Flowchart: A graphical diagram capturing programmatic control paths via
standardized geometric shapes.
Dry Run: A manual technique where a developer steps through an algorithm line by
line with sample data to verify correctness.
1.4.1 Overview of Design Tools
[Link] Flowcharts
Visual diagrams showing logical steps via standard shapes connected by directional
arrows.
Ovals: Represent start/end points.
Rectangles: Denote a processing step or calculation.
Diamonds: Indicate a conditional decision branch yielding True/False or Yes/No
paths.
Parallelograms: Represent input or output actions.
[Link] Decision Tables
Matrix grids mapping complicated logic rules to ensure every possible input
combination is handled.
Consists of condition stubs, action stubs, condition entries, and action entries.
Prevents logic gaps by exhausting every true/false combination of multiple nested
rules.
[Link] Decision Trees
Hierarchical tree diagrams mapping paths of choices, chance outcomes, and
dependencies.
Root nodes represent original problems; branches show options; leaves display final
outcomes.
Calculates risk, resource costs, and success probabilities across branching systems.
[Link] Pseudocode
Textual representation of logic using plain English combined with structured
programming constructs.
Employs standard coding terms like IF, THILE, FOR, and ELSE without strict syntax
limits.
Enables rapid logical experimentation before committing to a specific target
language syntax.
[Link] Algorithm
The foundational mathematical or logical formula used to complete a data task.
Must accept inputs, process data logically, and produce predictable outputs within
finite time constraints.
Design Tool Examples (Problem: Find the largest of two
numbers)
Pseudocode Example
text
START
INPUT num1, num2
IF num1 > num2 THEN
DISPLAY num1 + " is larger"
ELSE IF num2 > num1 THEN
DISPLAY num2 + " is larger"
ELSE
DISPLAY "Both numbers are equal"
ENDIF
END
Use code with caution.
Algorithm Example
1. Initialize variables num1 and num2.
2. Accept input values from the user for num1 and num2.
3. Evaluate if num1 is greater than num2. If true, choose num1 as the maximum and skip
to step 6.
4. Evaluate if num2 is greater than num1. If true, choose num2 as the maximum and skip
to step 6.
5. If neither condition is true, determine that both numbers are equivalent.
6. Display the determined outcome to the user interface.
7. Terminate execution.
1.4.2 Selecting Design Tools Based on Requirements and
Complexity
Simple Linear Algorithms: Apply pseudocode to quickly outline logic steps for
development teams.
UI/UX Navigation Flows: Deploy structural flowcharts to visualize user interaction
paths easily.
Complex Multi-Variable Policies: Use decision tables to ensure no business logic
branches are missed.
1.5 Identification of Program Writing Tools
Key Definitions
Source Code: Human-readable statements written in a programming language by a
developer.
Machine Code: Binary instructions (0s and 1s) directly readable and executable by
a computer CPU.
Bytecode: An intermediate code format produced by compiling source code,
designed to run on a virtual machine (e.g., JVM).
Breakpoint: An intentional stopping flag placed in source code to pause program
execution during debugging.
1.5.1 Common Program Writing Tools and IDEs
[Link] Text Editors
Lightweight, fast utilities used to manipulate plain text files without rich document
layout formatting.
Feature essential syntax highlighting, bracket matching, and auto-indentation (e.g.,
VS Code, Vim).
Consume minimal system memory, making them highly responsive across older or
low-spec computers.
[Link] Compilers and Linkers
Compilers: Transform high-level source code into native binary machine files or
intermediate bytecode formats.
Linkers: Collect disparate object files and dynamic library components to compile a
single executable file.
Catch syntax defects, type mismatches, and structural errors during the initial
compilation stage.
[Link] Debuggers
Runtime tracing tools used to pause execution at specific lines of code via user-
defined breakpoints.
Allow engineers to step through loop iterations and inspect live variable memory
states interactively.
Isolate logical calculation mistakes, memory allocation leaks, and unexpected
runtime application crashes.
[Link] Integrated Development Environments (IDEs)
Comprehensive software platforms combining text editors, compilers, linkers, and
debuggers into one workspace.
Offer advanced code completion engines (IntelliSense), automated refactoring tools,
and database consoles.
Increase developer efficiency drastically at the expense of heavy RAM and CPU
consumption (e.g., IntelliJ, Visual Studio).
1.5.2 Evaluating Tools Based on System Requirements and
Preferences
Hardware Footprint: Choose plain text editors on machines with constrained
memory allocations or slow CPUs.
Codebase Volume: Use full IDEs for large enterprise applications to leverage global
search index engines.
Tool Extensibility: Select software with robust ecosystem marketplaces to integrate
third-party extensions and linting tools.