Computer Science · Theme B: Computational thinking and problem-solving
B3.1 — Fundamentals of OOP for a single class
Computer Science · SL / HL · syllabus-mapped notes
CS_B3.1.1
Evaluating the fundamentals of OOP
The five core concepts, and the advantages and disadvantages of OOP across scenarios.
Full note — freeObject-oriented programming (OOP) is a paradigm that models a problem as interacting objects , each bundling data with the behaviour that acts on it. To evaluate its fundamentals, first define the five named concepts, then weigh advantages against disadvantages. Class : a blueprint or template that defines the attributes and methods a kind of object will have. Object : a specific instance created from a class, holding its own attribute values. Inheritance : a child class derives the attributes and methods of a parent class, reusing and extending it. Encapsulation : bundling data with its methods and hiding internal state behind a controlled interface. Polymorphism : one interface, such as a shared method name, behaving differently depending on the object it acts on. e.g. a Car class models a real-world entity: attributes make and speed; methods accelerate() and brake(). Each actual car on the road is an object. Evaluation across scenarios Models reality closely : real-world entities map to classes, so large systems are easier to reason about. Reusability : inheritance and composition let existing, tested code be reused rather than rewritten. Maintainability : encapsulation limits how a change ripples outward, so code is easier to modify and debug. Runtime overhead : object creation and method dispatch can use more memory and time than plain procedural code. Overkill for small tasks : deep hierarchies and boilerplate add complexity to simple, linear scripts. Easy to misuse : badly chosen abstraction or inheritance produces fragile, tightly-coupled designs. Judgement: OOP is appropriate for large, evolving systems with many related entities; for small, linear or highly performance-critical tasks a procedural or functional approach can be the better choice.
CS_B3.1.2
Designing classes with UML
Turning requirements into classes, methods and behaviour shown as a UML class diagram.
You must be able to construct a design of classes, their methods and behaviour from application requirements, and represent it with a unified modelling language (UML) class diagram to aid software design and planning. From requirements to classes Nouns in the requirements often become classes …
CS_B3.1.3
Static versus non-static members
Class variables and methods shared by all objects versus per-object instance members.
You must be able to distinguish static (class) from non-static (instance) variables and methods, including their usage and scope. Code is required. Non-static (instance) member : belongs to each object; every object has its own copy, accessed through that object. Static (class) member : belongs …
CS_B3.1.4
Defining classes and instantiating objects
Writing a class, the constructor's role in initializing state, and creating objects.
You must be able to construct code that defines a class and creates (instantiates) objects from it. Code is required. The constructor A constructor initializes an object's state, setting initial values for its attributes at the time of creation, so the object begins in a …
CS_B3.1.5
Encapsulation and information hiding
Bundling data with methods and using private and public to control access.
You must be able to explain and apply encapsulation and information hiding, using access modifiers to control access to class members. Code is required. Encapsulation : bundling attributes and the methods that operate on them together inside one class. Information hiding : hiding internal state …
