Object Oriented programming is a programmign model that organises software design around data and objects rather than logic and functions.
Data is stored in classes. It gives the layout and style of the data, plus "rules" for editing and manipulating the data (allowing edits from within the class only, or specific other functions). This restriction of access is called encapsulation. Abstraction is a technique where the programmer "hides" parts of the class to make simpler the user's interaction with the object. And one class can be useerd as a parent class to form the basis of a sub-class using a technique called inheritance.
The slide deck goes into more detail and the accompanying worksheet will help you to understand some basic concepts of OOP.
The following activities are sourced and adapted from "Object Oriented Programming - getting started for Australian teachers". Please follow the link for the full site and extra resources, including helpful tutorial videos.
The following links are for to basic Python tasks that introduce the concept of OOP by starting with basic tasks, reminding users of simple programming concepts and then building on these skills.
Pet Variables - The beginning. Reminding you about variables.
Pet Functions - Reminding you of functions
Pet Lists - Reminding you of Lists
Pet Dictionaries - Reminding you of dictionaries
Pet Class - Using the previous knowledge of variables, functions, lists and dictionaries, now we can define a class and do stuff with it.
Pet String Methods - adding functionality to classes using methods.
Pet List of objects - adding further functionality of lists to classes.
Car activity - An activity where a class of objects called car are instantiated, manipulated and otherwise muched around.
Object Oriented Programming Methods activity
Object Oriented Programming Private Methods activity
Object Oriented Private Protected Attributes activity
Get and Set attributes - where you get attributes adn set attributes from within code
Advanced Get and Set activity - more get/set goodness with advanced nerdery
Putting all this together into a text-adaventure style game
Figher Class activity
Improved Fighter Class activity
Fighter Health Attributes activity
Fighter Skill Attack activity
Fighter Inhertitance activity
Optimising code to run more efficiently is an important part of all programming. The Instantiation worksheet uses the Instantiation, Encapsulation and Polymorphism script.
This slide deck discsses the Design Process in OOP.
In it, we are introduced to facade patterns, a way of hiding the complex class structure from end users and instead presenting users with a familiar structure that is easy to understand and use. The example in the worksheet is a simple library facade.
This is the python script for the Library facade, which is disucssed and worked on in the worksheet. below.