0% found this document useful (0 votes)
26 views4 pages

L2 Lesson Plan - OOP - KS4

This document provides a lesson plan for teaching classes and objects in object-oriented programming. The lesson introduces key concepts like classes, objects, attributes, and methods. Students participate in activities where they create an animal class with getter and setter methods, then instantiate objects and access attribute values. Formative assessments include pair programming exercises and a vocabulary matching activity to check understanding of core object-oriented programming terms.

Uploaded by

Carlo Elopers
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
26 views4 pages

L2 Lesson Plan - OOP - KS4

This document provides a lesson plan for teaching classes and objects in object-oriented programming. The lesson introduces key concepts like classes, objects, attributes, and methods. Students participate in activities where they create an animal class with getter and setter methods, then instantiate objects and access attribute values. Formative assessments include pair programming exercises and a vocabulary matching activity to check understanding of core object-oriented programming terms.

Uploaded by

Carlo Elopers
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

KS4 – Object-oriented programming Lesson plan

Lesson 2 - Classes and objects

Lesson 2: Classes and Objects


Introduction
During this lesson, students will be introduced to the concepts of classes and objects
through a classification exercise to determine the properties shared by all animals. As the
lesson progresses, Students will learn and apply key terminology, and have the
opportunity to create an object class and instantiate that object.

Learning objectives
● Describe the relationship between a class and an object
● Model a real world problem using object oriented programming conventions.
● Define attributes and methods as a part of a class
● Use a constructor to create objects
● Use a method and access an attribute on an object

Key vocabulary
Class, object, instance, attribute, method, constructor, getter, setter

Preparation
Subject knowledge:

For this lesson you will need a solid understanding of the key principles of object-
oriented programming. You will also need to know how to create an object class in
Python, implement get and set methods and instantiate objects using the class.

You will need:


● Slides
● Activity 2 worksheet: Using getter methods
● Activity 3 worksheet: Using setter methods
● Plenary worksheet: Match the definition
● L2 Vocabulary Handout

It is also advisable that pairings for the pair programming activity are decided in
advance in order to not waste lesson time.

Page 1 Last updated: 19-01-21


KS4 – Object-oriented programming Lesson plan
Lesson 2 - Classes and objects

Assessment opportunities
In the pair programming activities (activity 3 and 4 in particular) there is an opportunity
to determine if students have grasped the concepts in the lesson. The plenary is a
keyword definition matching activity to see if students can match up the keywords from
the lesson to the correct definition.

Outline plan
Please note that the slide deck labels the activities in the top right-hand corner to help
you navigate the lesson.

*Timings are rough guides


Starter What is an animal?
activity
(Slides 2-4) Students are presented with the question “What is an animal?” and asked
how they would describe one to someone who has never seen one.
students may come up with lots of things that don’t necessarily apply to all
5 mins
animals. The idea here is to get students to really focus on those
characteristics that are common across all animals.

Some possible suggestions from students are shown on slide 2, and whilst
they are true, some are only applicable to a subset of the animal kingdom.

Try and prompt students to come up with a narrow list that applies to all
animals, such as the list you can show on slide 4.

Activity 1 Creating an object class


(Slides 6-
17) Start by introducing some terminology and defining object-oriented
programming. It is useful at this point to talk about the difference between
object-oriented programming and procedural programming, mentioning
15 mins
the top-down approach used for procedural. You should point out that if a
change were needed to be made in procedural programming, it would
need to be made in all lines of code that correspond to the change. This
differs from object-oriented programming where instantiated objects can
be defined and any changes to the object need only be made once.

You should then move on to show the examples on slides 7 and 8 where
cars and houses are defined as objects, showing what attributes and
methods or actions they can have. In both cases it is important to highlight
that the objects within their individual category share attributes, for
instance all cars have a make and model, but not all cars have the same
make and model.

With the aid of the video on slide 9, you can then introduce students to an
object class, this will explain that an object class is the template or blueprint
for creating objects of the same type.

Page 2 Last updated: 25-01-21


KS4 – Object-oriented programming Lesson plan
Lesson 2 - Classes and objects

Now that students have been introduced to the concept of an object, an


example of a constructor for an object should be explained using slide 10. In
the example there is an object of type cat that has been created, This cat
has been given values for its attributes such as Fishcake for the name,
ginger as the colour, as well as a description for the cat.

students will now follow a live coding session whilst pair programming with
another learner. You should demonstrate how to create a template for the
object Pet as shown starting on slide 12. The live coding/pair programming
activity should continue, creating a new file to demonstrate how to create
an instance of an object. Ensure students are paying attention up to the
point where the code is complete before attempting it themselves.

Finally, on slide 17, students are presented with the completed code for both
files and should be prompted to execute mypet.py, at this point it is
important to explain to students that whilst the program produces no
output at this stage, an instance of their object has been created in
memory.

Activity 2 Getting information using getter methods


(Slides 18-
27) Staying with the cat example, students are now introduced to getter
methods, showing what they would return should they be called on the cat
object.
15mins
Learned should now use activity 2 worksheet and complete the pair
programming activity to create getter methods for their object. An example
of what the code could look like is shown on slide 21. To test their
understanding thus far there is a question about what will be displayed on
the screen if the code is executed to reinforce the fact that nothing will be.

students should then use the information on the worksheet to incorporate


print statements in the mypet.py file that make use of the get methods.
They should test that this works by executing their code.

Finally, students can create their own method in their object class to
describe their pet. This will demonstrate how information can be obtained
through just calling one method that calls the getters itself.

A possible solution is shown on slide 27 for any students having difficulty. At


this point it would be beneficial to address any issues students may have
before asking them to move on.

Activity 3 Setting information using setter methods


(Slides 28-
29) In this short activity, students should continue programming in their pairs to
create setter methods. They are supplied with an example on the activity

Page 3 Last updated: 25-01-21


KS4 – Object-oriented programming Lesson plan
Lesson 2 - Classes and objects

worksheet and should use this as a guide to create a further two.


5 mins
A possible solution is shown on slide 30.

Activity 4 Create new instances of objects


(Slide 30)
Finally, now that students have been exposed to creating an object,
15 mins instantiating it, and creating getter/setter methods, students now need to
create three different types of pets, giving them a name, a species, and a
description. They should check everything is functioning properly by also
implementing a describe method in their objects. They can use their
completed activity sheets from activity 2 and 3 to assist them.

Plenary Match the keyword to the definition


(Slide 31)
Give students a few minutes to read the keywords and definitions and
5 mins decide on the matches. You can then ask individual students to match the
keyword to the definition.

Note that the slide uses animations to reveal the answer.

There is a vocabulary handout for you to give to the students, perhaps as a


reward for matching the definitions.

Homework N/A

Resources are updated regularly — the latest version is available at: ncce.io/tcc.

This resource is licensed under the Open Government Licence, version 3. For more information on this
licence, see ncce.io/ogl.

Page 4 Last updated: 25-01-21

You might also like