Download presentation
Presentation is loading. Please wait.
1
Lesson Objectives Aims Key Words
You should be able to identify the features of object oriented languages You should be able to distinguish between object oriented and procedural languages Identify benefits of object orientation Key Words
2
Object Oriented Programming
The two most common methods of programming are procedural and object oriented – but what does this mean? Mmm object orientation
3
Procedural Languages Procedural programming is all about giving the computer instructions… step by step – in sequence Procedural programming relies on procedures (aka routines/subs) containing instructions to be carried out by the computer
4
Object Oriented Programming (OOP)
Object Oriented Programming is where things get a bit cleverer and flexible Instructions are carried out using objects An object is part of the programme that is able to carry out actions and interact with other elements of the programme OOPs I did it again
5
Object Oriented Programming (OOP)
Objects have properties and methods… these are easily compared to real life objects We also rely on classes; these are the blueprints for our objects and outline some key features and capabilities of the object. Object: A person Property: Harold (name) Method: Pose for stock photos (something the object is capable of doing)
6
Classes So the class is a blueprint for our objects. They contain reusable elements that are common amongst a set of objects. Classes can contain properties and/or methods. Here’s a class diagram… Person Name Weight Eye Colour Talk Walk Class name Properties Methods
7
Classes Encapsulation is when properties for an object aren’t seen – they may be used by the object for calculations but we don’t see them Inheritance is when certain properties are inherited from one class to another to prevent repetition of properties or methods Superclass Person Name Weight Eye Colour getWeight() getEyeColour() Male Beard Length Beard Colour getBeardLength() Female getPresident() Is President? Subclasses
8
Object Ivor: Male Weight: 14st Eye Colour: Green Beard Length: 40cm Beard Colour: Grey Weight and Eye Colour have been inherited from the super class! Male Beard Length Beard Colour getBeardLength() Because of encapsulation the properties may be hidden (private)… we’ll need to use a method to check them. Hillary: Female Weight: 14st Eye Colour: Green Beard Length: 40cm Beard Colour: Grey getPresident() “Yes”
9
Which is better? Procedural programming provides little protection for data – it’s easy for variables to be overwritten by accident causing the programme to behave in a way that wasn’t intended It’s difficult to reuse parts of procedural code OOP takes advantage of elements having certain things in common with each other
10
Which is better? Procedural Programming is based on procedures operating based on data. OOP combines the two – procedures and data to form the objects
11
Review/Success Criteria
You should know You should be able to identify the features of object oriented languages You should be able to distinguish between object oriented and procedural languages Identify benefits of object orientation You you you oughta know
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.