Skip to main content

CBE NEXUS · UNDERGRADUATE TEXTBOOK SERIES

Chapter 4: Programming Fundamentals for Information Systems

Information Systems

Comprehensive study notes, practical workshops, diagrams and university-level assessment.

Undergraduate level · Chapter 4 of 16 · Year 1 foundations

Learning outcomes: Explain programming concepts; design algorithms; use data types, control structures and functions; select data structures; work with files and databases; build web and API features; test and debug programs; and apply secure and ethical coding practices.

Role of programming in information systems

Programming converts business rules and user requirements into executable instructions. Information Systems professionals use code to validate data, automate workflows, integrate services, produce reports and build interfaces. Programming is not only syntax: it requires problem definition, decomposition, algorithm design, data modelling, testing, security and maintenance. A program should be judged by whether it solves the intended problem accurately and safely.

A programmer works within an organisational context. The same calculation may be used in payroll, admissions, inventory or banking, but each domain has different rules, consequences and audit needs. Requirements must therefore be confirmed with stakeholders and translated into explicit acceptance criteria. Students should learn to explain assumptions, identify edge cases and document the intended behaviour before writing code.

In a practical exercise, write down the input domain, expected output, invalid cases and any side effects before implementation. Trace the algorithm with representative values, then test boundary and exceptional conditions. Explain the reason for the selected data structure and control flow, and state how correctness will be demonstrated. Good programming practice makes assumptions visible and keeps business rules separate from interface details wherever practical.

Programming languages and paradigms

A programming language provides syntax and semantics for expressing computation. High-level languages abstract many machine details and support faster development; lower-level languages provide closer control over hardware and memory. Compiled languages are translated before execution, interpreted environments execute or translate instructions at runtime, and many modern platforms combine compilation and virtual machines.

Procedural programming organises instructions into procedures and functions. Object-oriented programming organises state and behaviour around objects. Functional programming emphasises expressions, immutability and functions, while event-driven programming responds to events such as clicks, messages or sensor readings. Languages often support several paradigms. Choose based on task, ecosystem, performance, team skills and maintainability rather than popularity alone.

In a practical exercise, write down the input domain, expected output, invalid cases and any side effects before implementation. Trace the algorithm with representative values, then test boundary and exceptional conditions. Explain the reason for the selected data structure and control flow, and state how correctness will be demonstrated. Good programming practice makes assumptions visible and keeps business rules separate from interface details wherever practical.

Development environments and tools

An integrated development environment combines an editor, code navigation, debugging, build support and often testing tools. A compiler or interpreter executes the program; a package manager resolves dependencies; a terminal runs commands; and a debugger allows inspection of program state. Consistent tooling makes development repeatable across team members and environments.

Projects should use clear directory structures, meaningful filenames, documented setup steps and controlled configuration. Keep secrets out of source code and use environment variables or a secure secret store. Separate development and production settings. A reproducible environment helps another developer install dependencies, run tests and understand how the application is started without relying on undocumented personal settings.

In a practical exercise, write down the input domain, expected output, invalid cases and any side effects before implementation. Trace the algorithm with representative values, then test boundary and exceptional conditions. Explain the reason for the selected data structure and control flow, and state how correctness will be demonstrated. Good programming practice makes assumptions visible and keeps business rules separate from interface details wherever practical.

Algorithms and computational thinking

An algorithm is a finite, ordered and unambiguous sequence of steps for solving a problem. Computational thinking includes decomposition, pattern recognition, abstraction and algorithm design. Decomposition divides a complex task into manageable parts; abstraction focuses on essential information; pattern recognition identifies reusable structure; and algorithm design specifies a solution.

An algorithm should have defined inputs, outputs, preconditions, postconditions and termination. Correctness means it produces the required result for all inputs within its stated domain. Efficiency concerns time and memory resources. Students can express algorithms in structured English, pseudocode or flowcharts before implementing them in a language. Tracing sample inputs helps reveal missing branches and incorrect assumptions.

In a practical exercise, write down the input domain, expected output, invalid cases and any side effects before implementation. Trace the algorithm with representative values, then test boundary and exceptional conditions. Explain the reason for the selected data structure and control flow, and state how correctness will be demonstrated. Good programming practice makes assumptions visible and keeps business rules separate from interface details wherever practical.

Variables, constants and data types

A variable is a named storage location or binding whose value may change during program execution. A constant represents a value that should not be reassigned. Data types define the kinds of values and operations permitted, such as integers, floating-point numbers, strings, booleans, dates and structured records. Type systems help prevent invalid operations and clarify meaning.

Choose types carefully. Money should not normally be calculated with imprecise binary floating-point arithmetic when exact decimal values or integer minor units are required. Dates and times need time-zone awareness. Identifiers should not be treated as quantities merely because they contain digits. Null or missing values must be handled deliberately because absence is not always equivalent to zero, false or an empty string.

In a practical exercise, write down the input domain, expected output, invalid cases and any side effects before implementation. Trace the algorithm with representative values, then test boundary and exceptional conditions. Explain the reason for the selected data structure and control flow, and state how correctness will be demonstrated. Good programming practice makes assumptions visible and keeps business rules separate from interface details wherever practical.

Operators and expressions

Arithmetic operators perform numerical operations; comparison operators evaluate relationships; logical operators combine conditions; and assignment operators update values. Operator precedence determines evaluation order, but parentheses improve clarity. Integer division, floating-point rounding and implicit type conversion can create errors if programmers assume that all numeric operations behave identically.

An expression has a value and may have side effects. A condition should be designed so its truth is clear, especially where several logical operators are combined. Short-circuit evaluation may skip later expressions when the result is already determined. Students should test boundary values, negative numbers, zero, large values and unexpected types rather than checking only a typical example.

In a practical exercise, write down the input domain, expected output, invalid cases and any side effects before implementation. Trace the algorithm with representative values, then test boundary and exceptional conditions. Explain the reason for the selected data structure and control flow, and state how correctness will be demonstrated. Good programming practice makes assumptions visible and keeps business rules separate from interface details wherever practical.

Input, output and validation

Input is information supplied to a program by a user, file, device or another service. Output is information presented, stored or transmitted. Input validation checks that data conforms to expected type, range, length, format and business rules. Validation improves data quality and prevents many failures, but it does not replace authorisation or server-side security controls.

Validation should distinguish syntactic correctness from semantic validity. A date may have the correct format but be outside an allowed period; a student number may match a pattern but refer to no registered student. Error messages should explain how to correct a problem without disclosing sensitive implementation details. Output should be formatted for its audience and encoded safely for its display context.

In a practical exercise, write down the input domain, expected output, invalid cases and any side effects before implementation. Trace the algorithm with representative values, then test boundary and exceptional conditions. Explain the reason for the selected data structure and control flow, and state how correctness will be demonstrated. Good programming practice makes assumptions visible and keeps business rules separate from interface details wherever practical.

Selection and decision structures

Selection chooses which instructions to execute based on a condition. An if statement handles a condition and optional alternative; else-if chains represent multiple cases; and switch or match structures can make selection among known alternatives clearer. Conditions should cover all relevant possibilities and handle unexpected values explicitly.

Decision logic should be mutually understandable and avoid contradictory rules. For example, a grading algorithm must define how score boundaries are treated, whether missing work is distinct from zero and what happens when the score is outside the permitted range. A decision table can expose gaps and overlaps before implementation. Unit tests should include every branch and boundary.

In a practical exercise, write down the input domain, expected output, invalid cases and any side effects before implementation. Trace the algorithm with representative values, then test boundary and exceptional conditions. Explain the reason for the selected data structure and control flow, and state how correctness will be demonstrated. Good programming practice makes assumptions visible and keeps business rules separate from interface details wherever practical.

Iteration and loops

Iteration repeats instructions while a condition or collection rule holds. A for loop is useful when the number of repetitions or collection traversal is known; a while loop continues while a condition remains true; and a do-while pattern executes at least once. Loops should have a clear initial state, continuation condition and progress step.

Off-by-one errors occur when loop boundaries are incorrect. Infinite loops occur when the condition never becomes false or the state does not progress. Collection mutation during iteration can cause skipped or repeated elements. Test empty collections, one element, many elements and boundary indexes. For large datasets, consider memory use and whether streaming or pagination is more appropriate.

In a practical exercise, write down the input domain, expected output, invalid cases and any side effects before implementation. Trace the algorithm with representative values, then test boundary and exceptional conditions. Explain the reason for the selected data structure and control flow, and state how correctness will be demonstrated. Good programming practice makes assumptions visible and keeps business rules separate from interface details wherever practical.

Functions, procedures and modularity

A function packages a reusable operation and may return a value; a procedure performs an action and may communicate results through defined outputs. Parameters provide input, local variables limit scope, and return values make outcomes explicit. Functions should ideally perform one coherent task and have names that describe their behaviour.

Modularity reduces duplication and makes code easier to test and maintain. A function should document its contract, including expected inputs, output, side effects and exceptions. Avoid excessive parameters and hidden dependencies on global state. Pure functions are easier to reason about because the same input produces the same output without changing external state. Refactoring extracts repeated logic into well-named components.

In a practical exercise, write down the input domain, expected output, invalid cases and any side effects before implementation. Trace the algorithm with representative values, then test boundary and exceptional conditions. Explain the reason for the selected data structure and control flow, and state how correctness will be demonstrated. Good programming practice makes assumptions visible and keeps business rules separate from interface details wherever practical.

Arrays, lists and collections

An array stores a sequence of elements, often accessed by index. Lists provide ordered collections with operations for insertion, deletion and traversal. Sets represent unique values; maps or dictionaries associate keys with values; queues process items in arrival order; and stacks follow last-in-first-out behaviour. Choosing the right collection can simplify an algorithm and improve performance.

Indexing usually begins at zero in many languages, so the final valid index is one less than the collection length. Check bounds before access. A map is useful for fast lookup by identifier, while a list is suitable for ordered traversal. Sets help detect duplicates. Students should understand how insertion, lookup and deletion costs vary across collection implementations.

In a practical exercise, write down the input domain, expected output, invalid cases and any side effects before implementation. Trace the algorithm with representative values, then test boundary and exceptional conditions. Explain the reason for the selected data structure and control flow, and state how correctness will be demonstrated. Good programming practice makes assumptions visible and keeps business rules separate from interface details wherever practical.

Strings and text processing

Strings represent sequences of characters and support operations such as concatenation, slicing, searching, replacement and formatting. Text processing is common in information systems: names, addresses, reference numbers, search terms, imported files and report content all require careful handling. Unicode allows text from many writing systems, and character length may not equal byte length.

Never assume that a user-entered name contains only English letters or that a character occupies one byte. Normalisation can make equivalent text representations comparable. Trimming whitespace and validating structured identifiers may be appropriate, but destructive transformations can alter legitimate data. Escape or encode text for the context in which it is displayed, and use parameterised queries when text is sent to a database.

In a practical exercise, write down the input domain, expected output, invalid cases and any side effects before implementation. Trace the algorithm with representative values, then test boundary and exceptional conditions. Explain the reason for the selected data structure and control flow, and state how correctness will be demonstrated. Good programming practice makes assumptions visible and keeps business rules separate from interface details wherever practical.

Files and data formats

Programs read and write files to persist or exchange information. Text files are human-readable; CSV represents tabular values; JSON represents structured data; XML uses tagged elements; and binary formats store data in compact or application-specific forms. File handling should specify character encoding, delimiters, schema, line endings and error behaviour.

Always check whether a file exists, whether the application has permission, whether the content is valid and whether the operation completed. Large files may require streaming rather than loading everything into memory. Use safe filenames, size limits and malware controls for uploaded files. Write important files atomically where possible so an interrupted process does not leave a corrupted partial result.

In a practical exercise, write down the input domain, expected output, invalid cases and any side effects before implementation. Trace the algorithm with representative values, then test boundary and exceptional conditions. Explain the reason for the selected data structure and control flow, and state how correctness will be demonstrated. Good programming practice makes assumptions visible and keeps business rules separate from interface details wherever practical.

Object-oriented programming

An object combines state and behaviour. A class defines a type from which objects can be created. Encapsulation protects internal state behind methods; abstraction exposes essential operations; inheritance derives a specialised type from a base type; and polymorphism allows different types to respond through a common interface.

Inheritance should represent a genuine substitutable relationship and not merely reuse code. Composition often provides more flexible reuse by assembling objects with focused responsibilities. Constructors establish valid initial state, while access modifiers control visibility. Students should model classes around domain concepts and avoid classes that become large collections of unrelated operations.

In a practical exercise, write down the input domain, expected output, invalid cases and any side effects before implementation. Trace the algorithm with representative values, then test boundary and exceptional conditions. Explain the reason for the selected data structure and control flow, and state how correctness will be demonstrated. Good programming practice makes assumptions visible and keeps business rules separate from interface details wherever practical.

Exceptions and error handling

An exception signals that an operation could not proceed normally. Error handling determines whether the program can recover, retry, report the issue or terminate safely. Catch exceptions at a level that has enough context to respond meaningfully. Do not suppress errors silently, because this can leave users with incorrect results and operators without diagnostic evidence.

Distinguish expected validation failures from unexpected faults. A missing required field can be reported to the user; a database outage may require retry or a service-unavailable response; and a programming defect should be logged for investigation. Logs must avoid secrets and unnecessary personal data. Cleanup operations should run reliably, and transactions should roll back when a multi-step operation fails.

In a practical exercise, write down the input domain, expected output, invalid cases and any side effects before implementation. Trace the algorithm with representative values, then test boundary and exceptional conditions. Explain the reason for the selected data structure and control flow, and state how correctness will be demonstrated. Good programming practice makes assumptions visible and keeps business rules separate from interface details wherever practical.

Database programming and SQL integration

Applications commonly persist information in relational databases. SQL supports data definition, querying and modification. A program should use parameterised queries or prepared statements rather than concatenate untrusted input into SQL strings. Database connections should be managed efficiently, and credentials should be stored securely outside source code.

Transactions group related operations so that they succeed or fail consistently. ACID properties describe atomicity, consistency, isolation and durability. A registration operation may need to create a student record, enrolment and audit entry together. If one step fails, the transaction should roll back. Use constraints in the database as well as application validation to protect integrity.

In a practical exercise, write down the input domain, expected output, invalid cases and any side effects before implementation. Trace the algorithm with representative values, then test boundary and exceptional conditions. Explain the reason for the selected data structure and control flow, and state how correctness will be demonstrated. Good programming practice makes assumptions visible and keeps business rules separate from interface details wherever practical.

Web programming fundamentals

A web application combines browser technologies with server-side logic and data services. HTML provides document structure, CSS controls presentation and JavaScript adds interaction. The browser sends HTTP requests and receives responses. Server-side code authenticates users, validates input, applies business rules and accesses protected data. A clear separation of responsibilities makes the system easier to maintain.

Never trust client-side input or hide sensitive operations only by removing a button from the interface. The server must enforce permissions for every protected action. Use HTTPS, secure session settings, output encoding and appropriate anti-forgery protections. Responsive and accessible interfaces support different devices and users. Test network failures, repeated submissions and expired sessions.

In a practical exercise, write down the input domain, expected output, invalid cases and any side effects before implementation. Trace the algorithm with representative values, then test boundary and exceptional conditions. Explain the reason for the selected data structure and control flow, and state how correctness will be demonstrated. Good programming practice makes assumptions visible and keeps business rules separate from interface details wherever practical.

APIs and network communication

An API defines how software components communicate. HTTP APIs commonly exchange JSON representations. A request includes a method, URL, headers and sometimes a body; a response includes a status code, headers and optional content. Clear contracts specify allowed fields, validation, authentication, error responses and versioning.

Network communication can fail or be delayed. Clients need timeouts and controlled retry policies. Retrying a non-idempotent operation may create duplicate payments or orders, so idempotency keys and deduplication may be needed. Validate remote responses and treat external data as untrusted. Do not expose internal stack traces or credentials in API errors.

In a practical exercise, write down the input domain, expected output, invalid cases and any side effects before implementation. Trace the algorithm with representative values, then test boundary and exceptional conditions. Explain the reason for the selected data structure and control flow, and state how correctness will be demonstrated. Good programming practice makes assumptions visible and keeps business rules separate from interface details wherever practical.

Testing and debugging

Testing provides evidence that software behaves as expected. Unit tests examine small functions or modules; integration tests examine interactions; system tests evaluate the complete application; acceptance tests confirm business requirements; and regression tests check that changes have not broken existing behaviour. Test cases should include normal, boundary, invalid and exceptional conditions.

Debugging identifies and corrects the cause of a defect. Reproduce the problem, narrow the relevant code, inspect state and execution flow, form a hypothesis, change the smallest appropriate area and rerun tests. A test should fail for the known defect before the correction and pass afterward. Avoid changing several unrelated things at once because it makes cause and effect unclear.

In a practical exercise, write down the input domain, expected output, invalid cases and any side effects before implementation. Trace the algorithm with representative values, then test boundary and exceptional conditions. Explain the reason for the selected data structure and control flow, and state how correctness will be demonstrated. Good programming practice makes assumptions visible and keeps business rules separate from interface details wherever practical.

Version control and collaborative development

Version control records changes to source files and supports collaboration. A repository stores project history; commits capture coherent changes; branches isolate work; merges integrate contributions; and pull requests enable review. Meaningful commit messages explain intent. Teams should agree on naming, branching, review and release practices.

Conflicts occur when concurrent changes affect the same content. Resolve them by understanding both intentions rather than blindly accepting one side. Never commit secrets, generated clutter or local environment files. A repository should include a README, setup instructions, tests and dependency information. Version control is not a substitute for backups or secure release management.

In a practical exercise, write down the input domain, expected output, invalid cases and any side effects before implementation. Trace the algorithm with representative values, then test boundary and exceptional conditions. Explain the reason for the selected data structure and control flow, and state how correctness will be demonstrated. Good programming practice makes assumptions visible and keeps business rules separate from interface details wherever practical.

Secure coding and ethical practice

Secure coding treats data as untrusted, applies least privilege, validates input, encodes output, protects secrets and uses maintained dependencies. Common weaknesses include injection, broken access control, insecure direct object references, unsafe file uploads, weak session handling and sensitive information in logs. Threat modelling helps identify which weaknesses matter most in a particular application.

Programmers also have ethical responsibilities. They should protect personal information, avoid hidden harmful functionality, disclose limitations, respect intellectual property and report vulnerabilities through appropriate channels. Automated decisions should be tested for unfair outcomes and should provide human review where consequences are significant. Code quality includes the effects of the software on people and organisations.

In a practical exercise, write down the input domain, expected output, invalid cases and any side effects before implementation. Trace the algorithm with representative values, then test boundary and exceptional conditions. Explain the reason for the selected data structure and control flow, and state how correctness will be demonstrated. Good programming practice makes assumptions visible and keeps business rules separate from interface details wherever practical.

Performance and algorithmic complexity

Algorithm analysis estimates how resource use grows with input size. Big-O notation describes an upper-bound growth class, commonly used to compare time or space complexity. A linear search is O(n); binary search on sorted data is O(log n); and a simple nested comparison may be O(n²). Actual performance also depends on constants, hardware, data distribution and implementation.

Choose data structures and algorithms based on measured needs. Avoid premature optimisation, but recognise obvious inefficiencies such as repeated database queries inside a large loop. Profiling identifies real bottlenecks. Caching, indexing, pagination and batching can help, but each introduces trade-offs such as stale data, memory use or more complex error handling.

In a practical exercise, write down the input domain, expected output, invalid cases and any side effects before implementation. Trace the algorithm with representative values, then test boundary and exceptional conditions. Explain the reason for the selected data structure and control flow, and state how correctness will be demonstrated. Good programming practice makes assumptions visible and keeps business rules separate from interface details wherever practical.

Documentation and maintainability

Readable code communicates intent through clear names, small functions, consistent formatting and focused comments. Comments should explain why a non-obvious decision exists, not merely repeat what the code visibly does. Documentation should include setup, configuration, architecture, interfaces, data assumptions, known limitations and operational procedures.

Maintainability is supported by automated tests, code review, dependency updates, refactoring and clear ownership. Avoid duplicated business rules because different copies may diverge. Keep functions cohesive and remove obsolete code safely. A future developer should be able to understand how to run the project, where important rules live and how changes can be verified.

In a practical exercise, write down the input domain, expected output, invalid cases and any side effects before implementation. Trace the algorithm with representative values, then test boundary and exceptional conditions. Explain the reason for the selected data structure and control flow, and state how correctness will be demonstrated. Good programming practice makes assumptions visible and keeps business rules separate from interface details wherever practical.

Case study: student registration application

A college needs an application that allows students to register for a semester. The program collects a student identifier, verifies the student's active status, checks prerequisites and course capacity, records enrolment and returns a confirmation. It must prevent duplicate enrolments, protect student information and preserve an audit trail for administrators.

A suitable design separates input validation, business rules, database access and presentation. The registration operation uses a transaction so that enrolment and audit records are consistent. Tests cover unknown identifiers, inactive students, missing prerequisites, full classes, duplicate requests, database failures and successful registration. The server enforces permissions even if the interface hides registration controls from unauthorised users.

In a practical exercise, write down the input domain, expected output, invalid cases and any side effects before implementation. Trace the algorithm with representative values, then test boundary and exceptional conditions. Explain the reason for the selected data structure and control flow, and state how correctness will be demonstrated. Good programming practice makes assumptions visible and keeps business rules separate from interface details wherever practical.

Worked example: grade classification

Suppose a course uses the following illustrative classification: 70–100 Distinction, 60–69 Credit, 50–59 Pass and below 50 Fail. The algorithm must first reject values outside 0–100 and distinguish a missing mark from a mark of zero. Conditions should be ordered from the highest boundary downward so that 70 is not incorrectly classified as Credit.

Pseudocode: read mark; if mark is missing, report missing; else if mark is less than 0 or greater than 100, report invalid; else if mark is at least 70, return Distinction; else if mark is at least 60, return Credit; else if mark is at least 50, return Pass; otherwise return Fail. Boundary tests include 0, 49, 50, 59, 60, 69, 70 and 100.

In a practical exercise, write down the input domain, expected output, invalid cases and any side effects before implementation. Trace the algorithm with representative values, then test boundary and exceptional conditions. Explain the reason for the selected data structure and control flow, and state how correctness will be demonstrated. Good programming practice makes assumptions visible and keeps business rules separate from interface details wherever practical.

Worked example: algorithm efficiency

A program compares every pair of records in a list to find duplicates. If there are n records, the number of pair comparisons grows approximately as n(n−1)/2. For n = 100, this is 4,950 comparisons; for n = 1,000, it is 499,500. The approach has quadratic O(n²) growth and becomes expensive as the dataset expands.

A set-based method inserts each identifier into a set and checks whether it has appeared before. With an appropriate hash-set implementation, expected lookup and insertion are approximately constant time, so the overall expected work grows approximately linearly, O(n). Memory use increases because the set stores identifiers. The correct choice depends on dataset size, memory constraints and the required behaviour.

In a practical exercise, write down the input domain, expected output, invalid cases and any side effects before implementation. Trace the algorithm with representative values, then test boundary and exceptional conditions. Explain the reason for the selected data structure and control flow, and state how correctness will be demonstrated. Good programming practice makes assumptions visible and keeps business rules separate from interface details wherever practical.

Professional practice and capstone preparation

Programming projects should begin with a clear problem statement, stakeholders, scope, acceptance criteria and risks. Teams plan work in small increments, use version control, review code, test continuously and demonstrate working outcomes. A capstone should include a requirements summary, architecture, data model, test evidence, user guidance and a deployment or demonstration plan.

Students should be able to defend design decisions, explain limitations and show evidence that the application behaves correctly. A demonstration alone is insufficient if it uses only ideal data. Include error cases, security checks and accessibility considerations. Reflect on what changed during development, what technical debt remains and how the system could be maintained responsibly.

In a practical exercise, write down the input domain, expected output, invalid cases and any side effects before implementation. Trace the algorithm with representative values, then test boundary and exceptional conditions. Explain the reason for the selected data structure and control flow, and state how correctness will be demonstrated. Good programming practice makes assumptions visible and keeps business rules separate from interface details wherever practical.

Practical programming workshop 1: Role of programming in information systems

Develop a small feature for a college information system. The feature must have a clear user or service purpose, documented inputs, outputs, validation rules and error behaviour. Apply role of programming in information systems to a realistic task such as checking course capacity, calculating a fee balance, searching a student record or preparing a class list. Describe the algorithm before coding and identify the data that must remain protected.

Programming converts business rules and user requirements into executable instructions. Information Systems professionals use code to validate data, automate workflows, integrate services, produce reports and build interfaces. Programming is not only syntax: it requires problem definition, decomposition, algorithm design, data modelling, testing, security and maintenance. A program should be judged by whether it solves the intended problem accurately and safely.

A programmer works within an organisational context. The same calculation may be used in payroll, admissions, inventory or banking, but each domain has different rules, consequences and audit needs. Requirements must therefore be confirmed with stakeholders and translated into explicit acceptance criteria. Students should learn to explain assumptions, identify edge cases and document the intended behaviour before writing code.

Prepare a test table with normal, boundary, invalid and exceptional inputs. State the expected result for each test and record the actual result after execution. Include at least one failure scenario, such as a missing record or unavailable database. Review the code for readability, security and unnecessary duplication. Explain how a future developer would run, test and maintain the feature.

Practical programming workshop 2: Programming languages and paradigms

Develop a small feature for a college information system. The feature must have a clear user or service purpose, documented inputs, outputs, validation rules and error behaviour. Apply programming languages and paradigms to a realistic task such as checking course capacity, calculating a fee balance, searching a student record or preparing a class list. Describe the algorithm before coding and identify the data that must remain protected.

A programming language provides syntax and semantics for expressing computation. High-level languages abstract many machine details and support faster development; lower-level languages provide closer control over hardware and memory. Compiled languages are translated before execution, interpreted environments execute or translate instructions at runtime, and many modern platforms combine compilation and virtual machines.

Procedural programming organises instructions into procedures and functions. Object-oriented programming organises state and behaviour around objects. Functional programming emphasises expressions, immutability and functions, while event-driven programming responds to events such as clicks, messages or sensor readings. Languages often support several paradigms. Choose based on task, ecosystem, performance, team skills and maintainability rather than popularity alone.

Prepare a test table with normal, boundary, invalid and exceptional inputs. State the expected result for each test and record the actual result after execution. Include at least one failure scenario, such as a missing record or unavailable database. Review the code for readability, security and unnecessary duplication. Explain how a future developer would run, test and maintain the feature.

Practical programming workshop 3: Development environments and tools

Develop a small feature for a college information system. The feature must have a clear user or service purpose, documented inputs, outputs, validation rules and error behaviour. Apply development environments and tools to a realistic task such as checking course capacity, calculating a fee balance, searching a student record or preparing a class list. Describe the algorithm before coding and identify the data that must remain protected.

An integrated development environment combines an editor, code navigation, debugging, build support and often testing tools. A compiler or interpreter executes the program; a package manager resolves dependencies; a terminal runs commands; and a debugger allows inspection of program state. Consistent tooling makes development repeatable across team members and environments.

Projects should use clear directory structures, meaningful filenames, documented setup steps and controlled configuration. Keep secrets out of source code and use environment variables or a secure secret store. Separate development and production settings. A reproducible environment helps another developer install dependencies, run tests and understand how the application is started without relying on undocumented personal settings.

Prepare a test table with normal, boundary, invalid and exceptional inputs. State the expected result for each test and record the actual result after execution. Include at least one failure scenario, such as a missing record or unavailable database. Review the code for readability, security and unnecessary duplication. Explain how a future developer would run, test and maintain the feature.

Practical programming workshop 4: Algorithms and computational thinking

Develop a small feature for a college information system. The feature must have a clear user or service purpose, documented inputs, outputs, validation rules and error behaviour. Apply algorithms and computational thinking to a realistic task such as checking course capacity, calculating a fee balance, searching a student record or preparing a class list. Describe the algorithm before coding and identify the data that must remain protected.

An algorithm is a finite, ordered and unambiguous sequence of steps for solving a problem. Computational thinking includes decomposition, pattern recognition, abstraction and algorithm design. Decomposition divides a complex task into manageable parts; abstraction focuses on essential information; pattern recognition identifies reusable structure; and algorithm design specifies a solution.

An algorithm should have defined inputs, outputs, preconditions, postconditions and termination. Correctness means it produces the required result for all inputs within its stated domain. Efficiency concerns time and memory resources. Students can express algorithms in structured English, pseudocode or flowcharts before implementing them in a language. Tracing sample inputs helps reveal missing branches and incorrect assumptions.

Prepare a test table with normal, boundary, invalid and exceptional inputs. State the expected result for each test and record the actual result after execution. Include at least one failure scenario, such as a missing record or unavailable database. Review the code for readability, security and unnecessary duplication. Explain how a future developer would run, test and maintain the feature.

Practical programming workshop 5: Variables, constants and data types

Develop a small feature for a college information system. The feature must have a clear user or service purpose, documented inputs, outputs, validation rules and error behaviour. Apply variables, constants and data types to a realistic task such as checking course capacity, calculating a fee balance, searching a student record or preparing a class list. Describe the algorithm before coding and identify the data that must remain protected.

A variable is a named storage location or binding whose value may change during program execution. A constant represents a value that should not be reassigned. Data types define the kinds of values and operations permitted, such as integers, floating-point numbers, strings, booleans, dates and structured records. Type systems help prevent invalid operations and clarify meaning.

Choose types carefully. Money should not normally be calculated with imprecise binary floating-point arithmetic when exact decimal values or integer minor units are required. Dates and times need time-zone awareness. Identifiers should not be treated as quantities merely because they contain digits. Null or missing values must be handled deliberately because absence is not always equivalent to zero, false or an empty string.

Prepare a test table with normal, boundary, invalid and exceptional inputs. State the expected result for each test and record the actual result after execution. Include at least one failure scenario, such as a missing record or unavailable database. Review the code for readability, security and unnecessary duplication. Explain how a future developer would run, test and maintain the feature.

Practical programming workshop 6: Operators and expressions

Develop a small feature for a college information system. The feature must have a clear user or service purpose, documented inputs, outputs, validation rules and error behaviour. Apply operators and expressions to a realistic task such as checking course capacity, calculating a fee balance, searching a student record or preparing a class list. Describe the algorithm before coding and identify the data that must remain protected.

Arithmetic operators perform numerical operations; comparison operators evaluate relationships; logical operators combine conditions; and assignment operators update values. Operator precedence determines evaluation order, but parentheses improve clarity. Integer division, floating-point rounding and implicit type conversion can create errors if programmers assume that all numeric operations behave identically.

An expression has a value and may have side effects. A condition should be designed so its truth is clear, especially where several logical operators are combined. Short-circuit evaluation may skip later expressions when the result is already determined. Students should test boundary values, negative numbers, zero, large values and unexpected types rather than checking only a typical example.

Prepare a test table with normal, boundary, invalid and exceptional inputs. State the expected result for each test and record the actual result after execution. Include at least one failure scenario, such as a missing record or unavailable database. Review the code for readability, security and unnecessary duplication. Explain how a future developer would run, test and maintain the feature.

Practical programming workshop 7: Input, output and validation

Develop a small feature for a college information system. The feature must have a clear user or service purpose, documented inputs, outputs, validation rules and error behaviour. Apply input, output and validation to a realistic task such as checking course capacity, calculating a fee balance, searching a student record or preparing a class list. Describe the algorithm before coding and identify the data that must remain protected.

Input is information supplied to a program by a user, file, device or another service. Output is information presented, stored or transmitted. Input validation checks that data conforms to expected type, range, length, format and business rules. Validation improves data quality and prevents many failures, but it does not replace authorisation or server-side security controls.

Validation should distinguish syntactic correctness from semantic validity. A date may have the correct format but be outside an allowed period; a student number may match a pattern but refer to no registered student. Error messages should explain how to correct a problem without disclosing sensitive implementation details. Output should be formatted for its audience and encoded safely for its display context.

Prepare a test table with normal, boundary, invalid and exceptional inputs. State the expected result for each test and record the actual result after execution. Include at least one failure scenario, such as a missing record or unavailable database. Review the code for readability, security and unnecessary duplication. Explain how a future developer would run, test and maintain the feature.

Practical programming workshop 8: Selection and decision structures

Develop a small feature for a college information system. The feature must have a clear user or service purpose, documented inputs, outputs, validation rules and error behaviour. Apply selection and decision structures to a realistic task such as checking course capacity, calculating a fee balance, searching a student record or preparing a class list. Describe the algorithm before coding and identify the data that must remain protected.

Selection chooses which instructions to execute based on a condition. An if statement handles a condition and optional alternative; else-if chains represent multiple cases; and switch or match structures can make selection among known alternatives clearer. Conditions should cover all relevant possibilities and handle unexpected values explicitly.

Decision logic should be mutually understandable and avoid contradictory rules. For example, a grading algorithm must define how score boundaries are treated, whether missing work is distinct from zero and what happens when the score is outside the permitted range. A decision table can expose gaps and overlaps before implementation. Unit tests should include every branch and boundary.

Prepare a test table with normal, boundary, invalid and exceptional inputs. State the expected result for each test and record the actual result after execution. Include at least one failure scenario, such as a missing record or unavailable database. Review the code for readability, security and unnecessary duplication. Explain how a future developer would run, test and maintain the feature.

Practical programming workshop 9: Iteration and loops

Develop a small feature for a college information system. The feature must have a clear user or service purpose, documented inputs, outputs, validation rules and error behaviour. Apply iteration and loops to a realistic task such as checking course capacity, calculating a fee balance, searching a student record or preparing a class list. Describe the algorithm before coding and identify the data that must remain protected.

Iteration repeats instructions while a condition or collection rule holds. A for loop is useful when the number of repetitions or collection traversal is known; a while loop continues while a condition remains true; and a do-while pattern executes at least once. Loops should have a clear initial state, continuation condition and progress step.

Off-by-one errors occur when loop boundaries are incorrect. Infinite loops occur when the condition never becomes false or the state does not progress. Collection mutation during iteration can cause skipped or repeated elements. Test empty collections, one element, many elements and boundary indexes. For large datasets, consider memory use and whether streaming or pagination is more appropriate.

Prepare a test table with normal, boundary, invalid and exceptional inputs. State the expected result for each test and record the actual result after execution. Include at least one failure scenario, such as a missing record or unavailable database. Review the code for readability, security and unnecessary duplication. Explain how a future developer would run, test and maintain the feature.

Practical programming workshop 10: Functions, procedures and modularity

Develop a small feature for a college information system. The feature must have a clear user or service purpose, documented inputs, outputs, validation rules and error behaviour. Apply functions, procedures and modularity to a realistic task such as checking course capacity, calculating a fee balance, searching a student record or preparing a class list. Describe the algorithm before coding and identify the data that must remain protected.

A function packages a reusable operation and may return a value; a procedure performs an action and may communicate results through defined outputs. Parameters provide input, local variables limit scope, and return values make outcomes explicit. Functions should ideally perform one coherent task and have names that describe their behaviour.

Modularity reduces duplication and makes code easier to test and maintain. A function should document its contract, including expected inputs, output, side effects and exceptions. Avoid excessive parameters and hidden dependencies on global state. Pure functions are easier to reason about because the same input produces the same output without changing external state. Refactoring extracts repeated logic into well-named components.

Prepare a test table with normal, boundary, invalid and exceptional inputs. State the expected result for each test and record the actual result after execution. Include at least one failure scenario, such as a missing record or unavailable database. Review the code for readability, security and unnecessary duplication. Explain how a future developer would run, test and maintain the feature.

Practical programming workshop 11: Arrays, lists and collections

Develop a small feature for a college information system. The feature must have a clear user or service purpose, documented inputs, outputs, validation rules and error behaviour. Apply arrays, lists and collections to a realistic task such as checking course capacity, calculating a fee balance, searching a student record or preparing a class list. Describe the algorithm before coding and identify the data that must remain protected.

An array stores a sequence of elements, often accessed by index. Lists provide ordered collections with operations for insertion, deletion and traversal. Sets represent unique values; maps or dictionaries associate keys with values; queues process items in arrival order; and stacks follow last-in-first-out behaviour. Choosing the right collection can simplify an algorithm and improve performance.

Indexing usually begins at zero in many languages, so the final valid index is one less than the collection length. Check bounds before access. A map is useful for fast lookup by identifier, while a list is suitable for ordered traversal. Sets help detect duplicates. Students should understand how insertion, lookup and deletion costs vary across collection implementations.

Prepare a test table with normal, boundary, invalid and exceptional inputs. State the expected result for each test and record the actual result after execution. Include at least one failure scenario, such as a missing record or unavailable database. Review the code for readability, security and unnecessary duplication. Explain how a future developer would run, test and maintain the feature.

Practical programming workshop 12: Strings and text processing

Develop a small feature for a college information system. The feature must have a clear user or service purpose, documented inputs, outputs, validation rules and error behaviour. Apply strings and text processing to a realistic task such as checking course capacity, calculating a fee balance, searching a student record or preparing a class list. Describe the algorithm before coding and identify the data that must remain protected.

Strings represent sequences of characters and support operations such as concatenation, slicing, searching, replacement and formatting. Text processing is common in information systems: names, addresses, reference numbers, search terms, imported files and report content all require careful handling. Unicode allows text from many writing systems, and character length may not equal byte length.

Never assume that a user-entered name contains only English letters or that a character occupies one byte. Normalisation can make equivalent text representations comparable. Trimming whitespace and validating structured identifiers may be appropriate, but destructive transformations can alter legitimate data. Escape or encode text for the context in which it is displayed, and use parameterised queries when text is sent to a database.

Prepare a test table with normal, boundary, invalid and exceptional inputs. State the expected result for each test and record the actual result after execution. Include at least one failure scenario, such as a missing record or unavailable database. Review the code for readability, security and unnecessary duplication. Explain how a future developer would run, test and maintain the feature.

Programming and systems diagrams

Program execution flow
Problem and requirements
↓
Algorithm / pseudocode
↓
Source code
↓
Compile or interpret
↓
Run, test and debug
↓
Maintain and improve
Three-layer application
Presentation — forms and user interaction
↓
Business logic — rules and validation
↓
Data access — parameterised queries and transactions
↓
Database — persistent records
Control structures
Input and initialise
↓
Condition?
↓
YES → execute branch / loop body
↓
NO → alternative or exit
↓
Output and terminate
Secure registration transaction
Authenticate user
↓
Authorise registration action
↓
Validate student and course rules
↓
Begin database transaction
↓
Write enrolment + audit record
↓
Commit or rollback
Test cycle
Define expected behaviour
↓
Create normal, boundary and error tests
↓
Execute test
↓
Compare actual with expected
↓
Fix defect and rerun regression suite

University examination and revision questions

Use pseudocode, short code fragments, traces and justified examples where appropriate. Model answers give the core marking points and should be expanded in formal examinations.

Question 1. Define an algorithm.

Model answer: A finite, ordered and unambiguous sequence of steps that transforms defined inputs into required outputs and terminates.

Question 2. Differentiate a compiler and an interpreter.

Model answer: A compiler translates source code before execution or into an intermediate form; an interpreter executes or translates instructions at runtime. Modern platforms may combine both approaches.

Question 3. Explain four computational-thinking skills.

Model answer: Decomposition divides problems; abstraction focuses on essentials; pattern recognition identifies repeated structure; algorithm design defines the solution steps.

Question 4. Distinguish variables and constants.

Model answer: A variable may be reassigned during execution; a constant represents a value intended not to change.

Question 5. Why are data types important?

Model answer: They define valid values and operations, clarify meaning and help prevent invalid computations and storage errors.

Question 6. Differentiate syntax and semantic validation.

Model answer: Syntax checks form or structure; semantic validation checks whether the value makes sense under business rules and context.

Question 7. Explain selection and iteration.

Model answer: Selection chooses a branch based on conditions; iteration repeats instructions while a condition or collection rule holds.

Question 8. What causes an infinite loop?

Model answer: A continuation condition never becomes false, often because the loop state does not progress or the condition is incorrectly defined.

Question 9. State the purpose of a function.

Model answer: It packages a coherent operation behind a defined interface, supports reuse, testing and abstraction, and may return a value.

Question 10. Compare arrays, lists, sets and maps.

Model answer: Arrays/lists hold ordered elements; sets hold unique elements; maps associate keys with values. Their operations and performance differ.

Question 11. What is encapsulation?

Model answer: It protects an object's internal state and exposes controlled operations through a public interface.

Question 12. Why prefer composition over unnecessary inheritance?

Model answer: Composition assembles focused objects and often reduces rigid class hierarchies, making behaviour easier to change and test.

Question 13. Explain exception handling.

Model answer: It detects abnormal conditions and responds through recovery, reporting, retry or safe termination while preserving diagnostics and cleanup.

Question 14. Why use parameterised SQL queries?

Model answer: They separate query structure from data values and reduce the risk of SQL injection.

Question 15. State the ACID properties.

Model answer: Atomicity, consistency, isolation and durability describe important guarantees of database transactions.

Question 16. What is an API?

Model answer: A defined interface through which software components request operations or exchange data under an agreed contract.

Question 17. Explain idempotency in network operations.

Model answer: Repeating an idempotent request has the same intended effect as performing it once, helping clients retry safely.

Question 18. Differentiate unit, integration and system testing.

Model answer: Unit tests examine small components; integration tests examine interactions; system tests evaluate the complete application.

Question 19. What is regression testing?

Model answer: Retesting existing behaviour after a change to detect unintended breakage.

Question 20. Explain version control.

Model answer: It records source changes, supports branching and merging, and enables collaboration, review and recovery of earlier versions.

Question 21. What does O(n) mean?

Model answer: The algorithm's resource use grows approximately in proportion to input size n.

Question 22. Compare linear and binary search.

Model answer: Linear search checks elements sequentially and is O(n); binary search repeatedly halves a sorted search space and is O(log n).

Question 23. Why should secrets not be stored in source code?

Model answer: Repositories may be copied or exposed; secrets should be managed through protected configuration or a secret store and rotated if compromised.

Question 24. Give four test cases for a grading program.

Model answer: Test lower and upper valid boundaries, values immediately around grade thresholds, missing input and out-of-range values.

Question 25. Why is server-side authorisation essential?

Model answer: A client can be modified or bypassed; the trusted server must enforce permissions for every protected operation.

Question 26. Explain the purpose of code review.

Model answer: It detects defects, security weaknesses and unclear design, spreads knowledge and improves consistency before changes are integrated.

Question 27. What is Big-O notation?

Model answer: A mathematical description of how algorithm resource requirements grow with input size, abstracting constants and lower-order terms.

Question 28. Describe a safe file-upload process.

Model answer: Check authentication and permission, enforce size and type limits, inspect content, use safe generated names, store outside executable paths and log outcomes appropriately.

Question 29. Why distinguish null from zero?

Model answer: Null represents missing or unknown information; zero is a real numeric value and can have a different business meaning.

Question 30. Explain a database transaction in registration.

Model answer: It groups related writes, such as enrolment and audit records, so they commit together or roll back together if an operation fails.

Question 31. Identify three ethical responsibilities of programmers.

Model answer: Protect privacy, avoid harmful or discriminatory functionality, respect intellectual property, disclose limitations and report vulnerabilities responsibly.

Official Education References

Use these official organisations for curriculum guidance, examinations and further learning information.