Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Programming Paradigms πŸ“

Learning Goals

By the end of this section you will:

  • understand what a programming paradigm is and why different paradigms are used

  • know how object-oriented programming (OOP) models software using classes and objects

  • identify and explain the four core principles of OOP: encapsulation, inheritance, polymorphism, and abstraction

  • describe how event-driven programs use events, event handlers, and event loops

  • understand the purpose and structure of the Model-View-Controller (MVC) pattern

  • explain how MVC supports modularisation and separation of concerns in application design

  • know how the controller connects the model and view in the MVC pattern

  • recognise when to use OOP, event-driven programming, or MVC depending on the type of application

Object-Oriented Programming (OOP)ΒΆ

Object-Oriented Programming (OOP) is a coding approach that structures software around objects, which represent real-world entities or ideas. Each object is created from a class, which acts as a blueprint. Objects have attributes (data) and methods (functions) that define how they behave.

The four core principles of OOP are:

  1. Encapsulation – Hides an object’s internal details and allows interaction only through defined methods, helping protect data and reduce complexity.

  2. Inheritance – Lets one class inherit properties and methods from another, promoting code reuse and reducing repetition.

  3. Polymorphism – Allows objects of different classes to be treated as the same type, enabling flexible and dynamic code.

  4. Abstraction – Focuses on the essential features of an object while hiding unneeded details, simplifying complex systems.

OOP helps create clean, modular, and reusable code, making it a common choice in modern software development.

Python fully supports OOP and is one of the most widely used OOP languages today.

We explore these ideas in the Deepest Dungeon course. For a refresher, start with the OOP Primer.


Event-Driven ProgrammingΒΆ

Event-driven programming is a style of programming where the program’s behaviour is controlled by events, such as user actions, system signals, or messages from other parts of the system. Instead of running in a set order, the program waits for events and responds to them by running specific code called event handlers.

Key concepts include:

  1. Events – Actions or signals that trigger code execution, such as mouse clicks, key presses, file downloads, or timer updates.

  2. Event Handlers – Functions or methods that run when a specific event occurs. They define the response to that event.

  3. Event Loop – A continuous loop that listens for events and sends them to the right handler when they happen.

Event-driven programming is widely used in GUIs, web development, games, and any system that needs to react to external inputs. It is supported by many languages including JavaScript (for the web), Python (with tools like Tkinter), and C# (with Windows Forms).


MVC Architecture Pattern πŸ“ΒΆ

The Model-View-Controller (MVC) pattern is a design approach that makes complex applications easier to manage by breaking them into modular parts. It is an example of modularisation and decomposition.

MVC architecture

Parts of the MVC are:

Why use MVC?ΒΆ

MVC supports separation of concerns (SoC) by keeping data, user interface, and logic separate. This makes the codebase easier to organise, test, and updateβ€”especially when multiple developers are working on different parts of the application.