ZIMFundi
Sign inJoin free

Topic 5 of 8 · Form 6

Programming paradigms and object-oriented programming

Try–catch blocks; testing strategies: white-box, black-box, alpha, beta, acceptance; test data: normal, boundary, erroneous.

Notes for this topic 1 file, in order

Create a free account to download PDFs.

  1. PDFProgramming paradigms and object-oriented programming – Computer Science notes (ZIMSEC A Level)47.8 KB

Paradigms

  • Procedural (imperative): sequences of instructions and procedures (Pascal, C).
  • Object-oriented (Java, Python, C++): classes and objects.
  • Declarative/logic (Prolog): facts and rules; the system finds solutions.
  • Functional (Haskell): functions without side effects.
  • Low-level (assembly).

Object-oriented concepts

  • Class: a blueprint with attributes (properties) and methods.
  • Object: an instance of a class.
  • Encapsulation: data and methods bundled; attributes kept private and accessed through methods (getters and setters).
  • Inheritance: a subclass gains the attributes and methods of a superclass and can add its own.
  • Polymorphism: methods with the same name behave differently in different classes (overriding).
  • Constructor: a method that initialises a new object.

Worked example: Define a class Student with private Name and Mark, a constructor and a method to return the grade.

CLASS Student

   PRIVATE Name : STRING

   PRIVATE Mark : INTEGER

   PUBLIC PROCEDURE NEW(n, m)

      Name ← n

      Mark ← m

   ENDPROCEDURE

   PUBLIC FUNCTION Grade() RETURNS STRING

      IF Mark >= 50 THEN RETURN "Pass" ELSE RETURN "Fail" ENDIF

   ENDFUNCTION

ENDCLASS

Exception handling and testing

Try–catch blocks; testing strategies: white-box, black-box, alpha, beta, acceptance; test data: normal, boundary, erroneous.

Software development

Waterfall, iterative and rapid application development (RAD) life cycles; program maintenance (corrective, adaptive, perfective).

Exam tip: Explain OOP terms with an example from your own code – definitions alone score lower.

Check yourself

  1. What is encapsulation?
  2. Give an example of inheritance.
  3. Distinguish between white-box and black-box testing.
Show answers
  1. Bundling data with the methods that act on it, and restricting direct access to the data.
  2. e.g. a class Car inherits from a class Vehicle, gaining its attributes and methods.
  3. White-box tests the internal logic and paths; black-box tests inputs against expected outputs without looking at the code.
Next topicDatabases

Questions about this topic (0)

No questions about this topic yet.