Software Development  ·  Level 6
Object Oriented Programming

Chapter 1: Apply computer programming skills

📚 5 Topics
⚑ What you will be able to do

By the end of this chapter, you will be able to:

  • Identify different types of programming languages based on what the user needs.
  • Apply the right programming paradigms to solve problems effectively.
  • Follow the program development life cycle accurately from start to finish.
  • Use program design tools effectively to create solutions that meet user requirements.
  • Choose the appropriate program writing tools based on the system’s needs.

These skills will help you create software that truly fits what users want, making you a valuable programmer in the real world!

Compiled by: Ann Chebet

Object Oriented Programming (OOP) forms a cornerstone of modern software development, enabling programmers to create modular, reusable, and maintainable code. In the Kenyan software industry, where diverse applications from banking systems to mobile platforms are rapidly evolving, mastering OOP principles is essential for delivering robust solutions. This chapter focuses on applying programming skills by exploring programming language types, criteria for language selection, and practical exercises involving class creation and collaborative development. These competencies prepare software developers to work effectively both individually and in teams, reflecting real-world software engineering practices.

1.1 Programming Language Types

Programming languages are the tools through which a developer turns human logic into instructions a computer can run. Languages differ in the way they ask the programmer to organise a program, in their syntax and in the environment where the finished program runs. A developer who understands these differences can choose a suitable language for work as varied as a stock-keeping app for a hardware shop, a booking system for a salon or firmware for a small device.

1.1.1 Overview of programming language categories

A programming language category groups languages by the main way they ask you to describe a computation. This unit covers three categories: procedural, object-oriented and functional. The same small job is solved in each of them below so that the differences can be seen in working code.

The job: a hardware shop order has three lines. Each line has a quantity and a unit price in Ksh: 4 items at 250, 10 items at 35 and 2 items at 1,200. The program must print the order total.

Line totals: 4 × 250 = 1,000; 10 × 35 = 350; 2 × 1,200 = 2,400.

Order total: 1,000 + 350 + 2,400 = 3,750.

Many languages belong to more than one category. Python, JavaScript and C++ let a programmer write in several styles, and Java now includes functional features. A language is placed in the category whose ideas shaped its design. The topic Programming Paradigms looks at the same styles as ways of thinking about a program.

1.1.1.1 Procedural

A procedural language organises a program as a sequence of instructions grouped into procedures, also called functions or subroutines. The programmer writes the steps in order, keeps data in variables and arrays, and calls procedures to carry out repeated work. The program state changes as variables are updated step by step.

Main features:

  • Step-by-step flow: Instructions run from top to bottom, with loops and conditions deciding which steps repeat or are skipped.
  • Procedures: A named block of code does one job, such as calculating a line total, and can be called from many places.
  • Shared data: Variables and arrays are kept separately from the procedures that use them, so a procedure receives the data it needs as arguments.
  • Close to the machine: Procedural languages give direct control over memory and hardware, which suits low-level work.
  • Simple execution model: The order in which things happen is easy to follow, which helps when a beginner traces a program by hand.

Typical languages are C, Pascal, Fortran and COBOL. C is widely used for operating system components, device drivers and the firmware inside embedded devices.

The order total in C:

#include <stdio.h>

double line_total(int quantity, double unit_price) {
    return quantity * unit_price;
}

int main(void) {
    int quantities[] = {4, 10, 2};
    double prices[] = {250.0, 35.0, 1200.0};
    double total = 0.0;

    for (int i = 0; i < 3; i++) {
        total += line_total(quantities[i], prices[i]);
    }
    printf("Total: Ksh %.2f\n", total);
    return 0;
}

Output:

Total: Ksh 3750.00

The loop visits the three positions of the arrays. The procedure line_total returns 1000.0, then 350.0, then 2400.0, and total grows to 3750.0.

Strengths and limits:

  • Speed and control: Compiled procedural code runs fast and uses little memory, which suits devices with limited resources.
  • Easy to learn: The step-by-step model is a good first model of how a computer executes instructions.
  • Data is exposed: Any procedure that can see an array can change it, so a mistake in one place can corrupt data used elsewhere.
  • Growth is difficult: In a large program with hundreds of procedures it becomes hard to know which procedure may change which data.
  • Reuse is limited: Related data and procedures are not bundled together, so copying a feature into another project means copying several separate pieces.

1.1.1.2 Object-oriented

An object-oriented language organises a program around objects. An object bundles data, called attributes or fields, with the procedures that work on that data, called methods. Objects are created from classes, and the program runs as objects send messages to each other by calling methods.

Main features:

  • Classes and objects: A class is the blueprint and each object is one item built from it, such as one order line with its own quantity and price.
  • Encapsulation: Data and methods sit together, and the class decides which parts other code may use.
  • Inheritance: A new class can reuse and extend an existing class, for example a special order line that adds a discount.
  • Polymorphism: Different classes can respond to the same method call in their own way.
  • Abstraction: A class shows what an object can do and hides how it does it, so users of the class need not know the inner details.

Java, C# and Kotlin are designed around classes. C++ and Python support classes alongside other styles. The later topics Implementing Objects and Classes, Applying Object Encapsulation, Implementing Class Inheritance and Implementing Polymorphism teach these ideas in full.

The order total in Java:

public class Order {
    public static void main(String[] args) {
        OrderLine[] lines = {
            new OrderLine(4, 250.0),
            new OrderLine(10, 35.0),
            new OrderLine(2, 1200.0)
        };
        double total = 0.0;
        for (OrderLine line : lines) {
            total += line.total();
        }
        System.out.printf("Total: Ksh %.2f%n", total);
    }
}

class OrderLine {
    private final int quantity;
    private final double unitPrice;

    OrderLine(int quantity, double unitPrice) {
        this.quantity = quantity;
        this.unitPrice = unitPrice;
    }

    double total() {
        return quantity * unitPrice;
    }
}

Output:

Total: Ksh 3750.00

Each OrderLine object holds its own quantity and price and knows how to calculate its own total. The main method no longer handles two parallel arrays: it asks each object for its total and adds the results, 1000.0 + 350.0 + 2400.0 = 3750.0.

Strengths and limits:

  • Models real things: Objects such as an order line, a customer or a booking match the things the user talks about, which makes requirements easier to translate into code.
  • Protected data: A class can keep its data private and allow changes only through its methods.
  • Reuse: Inheritance and well-built classes let a team reuse tested code in later projects.
  • Teamwork: Different developers can build different classes against an agreed design.
  • More planning: A small job needs more code than the procedural version, and a poor class design can be harder to repair than a poor procedure.

1.1.1.3 Functional

A functional language treats computation as the evaluation of functions. A function takes values in and gives a value out, and a pure function does nothing else: it does not change a variable outside itself and gives the same result every time for the same input. Functions are values too, so one function can be passed to another.

Main features:

  • Pure functions: A function depends only on its arguments, so it can be tested alone and gives predictable results.
  • Immutable data: Values are not changed after they are created. A new value is produced instead of updating an old one.
  • Functions as values: A function can be stored, passed as an argument and returned from another function.
  • Higher-order functions: Functions such as map, filter and fold apply another function to every item of a list, which replaces many loops.
  • Recursion: Repeated work is written as a function that calls itself, instead of a loop with a counter.

Typical languages are Haskell, Erlang, Elixir, OCaml, F# and Clojure. Erlang was designed for telecommunication systems that keep very many separate activities running at once. JavaScript, Python and Java are not purely functional, but each lets a programmer use a functional style.

The order total in Haskell:

orderTotal :: [(Int, Double)] -> Double
orderTotal orderLines = sum (map lineTotal orderLines)
  where
    lineTotal (quantity, price) = fromIntegral quantity * price

main :: IO ()
main = putStrLn ("Total: Ksh " ++ show (orderTotal [(4, 250), (10, 35), (2, 1200)]))

Output:

Total: Ksh 3750.0

The program has no loop and no variable that changes. The function map applies lineTotal to each pair, giving the list [1000.0, 350.0, 2400.0], and sum adds the list to 3750.0. The function fromIntegral converts the whole-number quantity to a decimal number so it can be multiplied by the price.

Strengths and limits:

  • Easier reasoning: With no hidden changes, a function can be understood from its own lines.
  • Safe for concurrent work: Immutable data cannot be changed by two activities at the same time, which removes one source of faults.
  • Short code for data transformations: Working through lists of records, such as order lines, takes only a few lines.
  • A different way of thinking: Learners used to loops and changing variables need time to think in functions and recursion.
  • Not every task fits: Programs that depend on a lot of changing state, such as an interactive screen, need extra techniques to be written in a purely functional style.

1.1.2 Criteria for selecting languages based on user requirements

Choosing a language starts with the user's requirements, then moves to the project's size, the speed needed, the team's skills, the target platform and the support available. A poor choice shows up later as slow programs, missed deadlines or code nobody can maintain, so a developer weighs these criteria before writing any code.

Project complexity and scope

A large system with many features and several developers benefits from a language with strong support for modular design, such as Java or C#. A small automation job, such as renaming files or producing a nightly stock report, is better served by Python or Bash because the code is short and quick to write.

Performance requirements

Programs that need high speed and low delay, such as firmware in a device or the engine of a game, are usually written in compiled languages such as C or C++. A website or a business app that must be built quickly can use a dynamic language such as JavaScript or Python, accepting slower execution in exchange for faster development.

Development team expertise

A team's familiarity with a language affects its productivity and the quality of its code. A software team that already works well in Python may choose it for a new project to use its existing skills and avoid the cost of training.

Platform compatibility

The target platform limits the choice. Android apps are written mainly in Kotlin or Java, and iPhone apps in Swift or Objective-C. Cross-platform frameworks use JavaScript or Dart. A developer finds out where the client's users will run the software before selecting a language.

Community support and ecosystem

A language with an active community offers many libraries, frameworks and tools, and answers to common problems are easy to find. Python's libraries for data analysis and machine learning are an example of an ecosystem that can shorten a project.

Applying the criteria

Example: the owner of a hardware shop asks for two things: a stock app that staff use on Android phones, and a nightly script that totals the day's sales into a report. For the app, platform compatibility points to Kotlin or Java. For the script, project size and speed of writing point to Python. The same client therefore receives two programs in two languages, each chosen for its own requirement.

Practice Questions

  1. Explain the main differences between procedural and object-oriented programming languages, citing examples relevant to Kenyan software projects. (6 marks)
  2. List and explain five criteria a Kenyan software development team should consider when selecting a programming language for a new mobile application. (10 marks)
  3. Write a simple class in any object-oriented language that models a "Book" with attributes for title, author, and price, including methods to apply a discount and display details. Provide sample code for instantiating an object of this class. (10 marks)
  4. Describe the steps and challenges involved in a group project where each member implements a different class based on a shared design. How can these challenges be mitigated? (8 marks)
The rest of this chapter
🔒

Create a free account to open more of this chapter.

Free: practical guides, quick cards, workplace scenarios and more.

Create a free account
🔒1.2 Programming Paradigms

Programming paradigms represent the fundamental styles or approaches to writing software. For software development professionals in Kenya, understanding these paradigms is crucial for selecting the right tools and methodologies to deliver efficient and maintai…

🔒1.4 Program Design Tools

Program design tools are essential in structuring and planning software development projects effectively. In Kenya’s dynamic software sector, where projects range from mobile banking apps to enterprise resource systems for county governments, selecting the app…

🔒1.5 Program Writing Tools

Efficient program writing tools are critical in transforming design documents into functioning software. In Kenya’s software development ecosystem, which includes startups and established firms serving sectors like finance and education, the choice of programm…

Chapter Summary

This chapter explored various programming language types, highlighting procedural, object-oriented, and functional categories, and discussed how to select a language based on specific user requirements. It then examined common programming paradigms, including imperative and declarative approaches, emphasizing the importance of choosing the right paradigm to suit project needs. The program development life cycle was described with its key stages such as planning, design, and implementation, alongside best practices for adapting these stages to different work contexts. Design tools like algorithms, flowcharts, wireframes, pseudocode, and decision tables were introduced, with guidance on selecting appropriate tools depending on project complexity and user requirements. The chapter also covered program writing tools and integrated development environments, evaluating options like Visual Studio and Eclipse based on system needs and developer preferences. Practical skills were reinforced through activities involving creating simple classes, instantiating objects, and engaging in collaborative projects where team members implement different classes from a shared design. Together, these topics provide a comprehensive foundation for applying computer programming skills effectively.

Self-Assessment

🔒 PDFDownload this self-assessment, with answers

A. Written Assessment

  1. Which of the following best describes a procedural programming language? (2 marks)
    a) Focuses on objects and their interactions
    b) Executes instructions sequentially using procedures or routines
    c) Emphasizes immutability and pure functions
    d) Uses declarative statements to define logic

  2. Identify two key differences between object-oriented and functional programming paradigms. (4 marks)

🔒20 more in this section.

Chapter Examination Questions

🔒 PDFDownload these examination questions, with worked answers

SECTION A (40 Marks) - Answer ALL Questions

  1. Explain the main difference between procedural and object-oriented programming languages, using an example relevant to a Kenyan banking application. (4 marks)
  2. Identify three criteria that a software developer in a Nairobi-based fintech company should consider when selecting a programming language for a mobile payment system. (4 marks)
🔒18 more in this section.

Chapter Practical Activities

Practical 1: Classify Programming Languages into Procedural, Object-Oriented, and Functional Categories

Software Development · Level 6
Object Oriented Programming
PRACTICAL ASSESSMENT
TIME: 3 HOURS
⬇ PDFCandidate Instructions (Candidate Tool)

Type: Individual

INSTRUCTIONS TO CANDIDATE:
1.  You are required to perform the following task:
i.  Classify the following programming languages into procedural, object-oriented, and functional categories using the provided classification table template (table size approx. A4).
2.  You have been provided with the following resources for the practical task:
Tools & EquipmentMaterials
Computer with Windows 7 OS or higherList of programming languages for classification
Installed Java Development Kit (JDK)Printed classification table template
NetBeans or Eclipse IDE
Flash disk or CD RW
⬇ PDFResources Required (Cutting List)
S/NItemQuantity
1Computer with Windows 7 OS or higher1 Pc per Candidate
2Installed Java Development Kit (JDK)1 Pc per Candidate
3NetBeans or Eclipse IDE1 Pc per Candidate
4Flash disk or CD RW1 Pc per Candidate
5List of programming languages for classification1 Set per Candidate
6Printed classification table template1 Sheet per Candidate
⬇ PDFAssessor Guide
Items to be EvaluatedMarks AvailableMarks ObtainedComments
TASK 1: Identify Programming Language Types
Candidate reads and understands the list of programming languages
(Award 2 marks for correctly identifying all languages)
2
Candidate uses IDE or notes to research language types if unsure
(Award 2 marks for effective use of IDE or research)
2
Candidate classifies each language into correct category: Procedural, Object-Oriented, or Functional
(Award 1 mark per correctly classified language, total 6 marks)
6
Sub-Total10
TASK 2: Document Classification Results
Candidate fills the classification table template neatly and legibly
(Award 3 marks for clear and complete documentation)
3
Candidate saves and backs up the completed classification table on flash disk
(Award 2 marks for correct saving and backup)
2
Sub-Total5
PRODUCT CHECKLIST
Classification table accurately lists languages under correct categories (Procedural, Object-Oriented, Functional)
(Award up to 10 marks for accuracy and completeness of classification)
10
Classification table is neat, legible, and properly formatted on A4 sheet
(Award up to 5 marks for presentation and formatting)
5
Sub-Total15
GRAND TOTAL30
ASSESSMENT OUTCOME:   ☐ Competent    ☐ Not Yet Competent (competent if at least 50%)

Practical 2: Select appropriate programming language based on user requirements

Software Development · Level 6
Object Oriented Programming
PRACTICAL ASSESSMENT
TIME: 4 HOURS
⬇ PDFCandidate Instructions (Candidate Tool)

Type: Individual

INSTRUCTIONS TO CANDIDATE:
1.  You are required to perform the following task:
i.  Prepare a written report recommending a programming language for a business application with key criteria and justification, approximately 1000 words.
2.  You have been provided with the following resources for the practical task:
Tools & EquipmentMaterials
Computer installed with Windows 10 OS or higherFlash disk
Internet access for research
Office suite software (Word Processor, Spreadsheet)
⬇ PDFResources Required (Cutting List)
S/NItemQuantity
1Computer installed with Windows 10 OS or higher1 Pc per Candidate
2Internet access for research1 Pc per Candidate
3Office suite software (Word Processor, Spreadsheet)1 Pc per Candidate
4Flash disk1 Pc per Candidate
⬇ PDFAssessor Guide
Items to be EvaluatedMarks AvailableMarks ObtainedComments
TASK 1: Analyze user requirements
Identified and listed user requirements clearly
(Award 3 marks for clear, complete listing of requirements or 0)
3
Researched programming languages suitable for the requirements
(Award 4 marks for thorough research covering at least 3 languages or 0)
4
Evaluated languages against criteria such as performance, ease of use, platform compatibility, and community support
(Award 5 marks for detailed evaluation with relevant criteria or 0)
5
Sub-Total12
TASK 2: Select and justify programming language
Selected the most appropriate programming language based on analysis
(Award 5 marks for a justified, logical selection or 0)
5
Prepared a written report with clear reasoning and supporting facts
(Award 6 marks for a well-structured report with justification or 0)
6
Included recommendations for future scalability and maintenance
(Award 4 marks for relevant recommendations or 0)
4
Sub-Total15
TASK 3: Present deliverable
Formatted report professionally with headings and bullet points
(Award 3 marks for professional formatting or 0)
3
Saved and submitted report on flash disk in Word or PDF format
(Award 2 marks for correct file format and submission or 0)
2
Sub-Total5
PRODUCT CHECKLIST
Report contains all required sections: user requirements, language options, evaluation, selection, justification, and recommendations
(Award 8 marks for complete, coherent report or 0)
8
Report length approximately 1000 words
(Award 4 marks for meeting length requirement or 0)
4
Report free from spelling and grammatical errors
(Award 3 marks for error-free writing or 0)
3
Sub-Total15
GRAND TOTAL47
ASSESSMENT OUTCOME:   ☐ Competent    ☐ Not Yet Competent (competent if at least 50%)
🔒

Free: practical guides, quick cards, workplace scenarios and more.

Create a free account
🔒Explain and Differentiate Programming Paradigms with ExamplesPractical 3
🔒Select and justify programming paradigm for a car rental system projectPractical 4
🔒Plan Program Development Life Cycle for Library Management SystemPractical 5
🔒Adaptation of Program Development Life Cycle for Specific Work RequirementsPractical 6
🔒Design Algorithm and Flowchart for Student Grade EvaluationPractical 7
🔒Develop pseudocode and decision table/tree for loan eligibilityPractical 8
🔒Selection of Program Design Tools Based on Project ComplexityPractical 9
🔒Install and Configure Visual Studio Code IDE for Java DevelopmentPractical 10
🔒Evaluate and compare programming tools for a system development projectPractical 11
🔒Create and demonstrate a simple class with object instantiation in JavaPractical 12
🔒Implement and Demonstrate Class Methods and Properties in JavaPractical 13
🔒Group Project: Implementing Assigned Classes for a Library Management SystemPractical 14
🔒Integrate and Test Multiple Classes in a Java OOP ProjectPractical 15
Flashcards 20 cards Study deck ▾
Question
1

↻ Tap card to reveal answer
🔒

18 more in this section.

Create a free account
Test Yourself 20 questions Start quiz ▾
0%
0 / 2
🔒

18 more in this section.

Create a free account
Am I competent?

At the start of this chapter we promised you would be able to:

  • Identify different types of programming languages based on what the user needs.
  • Apply the right programming paradigms to solve problems effectively.
  • Follow the program development life cycle accurately from start to finish.
  • Use program design tools effectively to create solutions that meet user requirements.
  • Choose the appropriate program writing tools based on the system’s needs.

Tick each one you can genuinely do.

So, are you there yet?

You're competent when you can confidently do 50% or more of what this chapter promised.

Sign in to record how you're doing.