Object Oriented Programming (OOP)

studied byStudied by 1 person
0.0(0)
learn
LearnA personalized and smart learning plan
exam
Practice TestTake a test on your terms and definitions
spaced repetition
Spaced RepetitionScientifically backed study method
heart puzzle
Matching GameHow quick can you match all your cards?
flashcards
FlashcardsStudy terms and definitions

1 / 30

31 Terms

1

Object-oriented programming (OOP)

A programming paradigm where the system is viewed as a set of objects, each with their own data (attributes) and procedures (methods), that can interact with each other. All processing is done by objects.

New cards
2

Programming paradigm

An overall approach to writing program code

New cards
3

Object

Partiular instance of a class

New cards
4

Attributes

Value held by an object

New cards
5

Instantiation

The process of making an instance of an object from the class (definition). The object is assigned to a reference variable. Multiple instances of objects can be created. Each must have its own reference variable.

New cards
6

Class (definition)

A template / blueprint for an object and defines the state (the properties of the objects, given by attributes) and behaviour (actions it can perform, given by methods) of an object

New cards
7

UML

abbreviation of Unified Modeling Language

New cards
8

Class diagrams

Used to plan what attributes and methods a class will have. Each class is a box with three sections:

  • Name of the class at the top

  • Attributes and their data types in the middle section  

  • The methods including parameters and returned data types at the bottom

<p>Used to plan what attributes and methods a class will have. Each class is a box with three sections:</p><ul><li><p>Name of the class at the top</p></li><li><p>Attributes and their data types in the middle section&nbsp;&nbsp;</p></li><li><p>The methods including parameters and returned data types at the bottom</p></li></ul><p></p>
New cards
9

Methods

Actions an object can perform

New cards
10

Constructor

  • Special method that creates an instance of an object from a class

  • It carries out any actions that are needed for this, such as setting the initial values of the attributes

  • ____ have specific names (depends on the language)

New cards
11

Reference variable

Holds the address of the location in memory at which the specific object can be found. Whenever an instance of an object is created, it must be assigned to a _______

New cards
12

Access modifiers

Specify which properties (attributes and methods) can be accessed from outside the class. One of:

  • Public

  • Private

  • Protected

New cards
13

Public (attributes or methods)

(Attributes or methods) that can be accessed/called from another part of the program (outside the class). Most methods are _____, but almost all attributes are not.

New cards
14

Private (attributes or methods)

(Attributes or methods) that can not be accessed/called from another part of the program (outside the class). Attributes are almost always ____, whereas most methods tend not to be.

New cards
15

How objects interect with each other

They use 'message passing'; (this just means that) they call each other's public methods.

New cards
16

Encapsulation

When attributes are declared as private so can only be accessed and modified by public methods. This hides the data (attributes), making programs less complex by protecting data from being accidentally edited by other parts of the program.

New cards
17

Accessors

Special methods that exist to get the value of an attribute. (aka getters)

New cards
18

Mutators

Special methods that exist to set or change the value of an attribute.(aka setters)

New cards
19

Designing classes to be stand-alone allows…

…allows class designers to change the implementation details without any adverse effect on the applications that make use of them.

New cards
20

Benefits of making classes self-contained

  • The class can be (re)used in other applications

  • You can change the internal workings of any class, as long as the public interface isn't changed

New cards
21

Inheritance

When a child class / subclass / derived class takes on attributes and methods of a parent class / superclass / base class

New cards
22

Overriding inherited methods

Inherited methods can be _____ to change their functionality and make the behaviour more appropriate to the subclass. Is a form of polymorphism.

New cards
23

Protected property

A property that can be directly accessed by a subclass

New cards
24

Extending a subclass

Giving a subclass additional attributes and methods

New cards
25

Polymorphism

Fundamental OOP concept. It is the ability of an object to specialise its behavior based on its type; when a method is called, the code that is executed will depend on the object type. Two examples (you need to know) of how this is achieved is:

  • Method overriding

  • Method overloading

New cards
26

Method overloading

Having multiple methods of the same name, but that differ in terms of their parameter list, in a class. When one of these methods is called, the one with the matching parameter list is executed. Is a form of polymorphism.

New cards
27

Method signature

Combination of a method identifier and its parameter list

New cards
28

Advantages of OOP

  • Usually easier for us to think in terms of objects (and their attributes & behavious) than to think procedurally

  • Prewritten classes promote and support code reuse

  • Classes are highly modular, and this means that they are easy to maintain

  • Encapsulation provides a high level of protection for data - ensures that the data can never be modified carelessly and that any associated actions also happen (e.g. when a goal is scored in a game, you can make sure the player's score is incremented)

New cards
29

Disadvantages of OOP

  • OOP design techniques can result in a much larger, more complex system being built in order to achieve a result

  • Potential performance degredation (higher latency and increased resource consumption)

    • OOP relies on message passing for communication between objects

    • Systems with high volumes of message passing can suffer from the overhead involved in message creation, transmission, and processing

    • This can intruduce latency and increase resource consumption

  • Inheritance can have unintended consequences - objects can acquire the ability to do things that don't make sense (e.g. flying pigs)

  • Objects can take up a relatively large amount of memory as they typically require memory allocation for metadata (like pointers to methods and class information) as well as their own attributes.

New cards
30

Inheritence diagram

Inheritance is shown with open-headed arrows that point up from the child class to the parent class

<p>Inheritance is shown with open-headed arrows that point up from the child class to the parent class</p>
New cards
31

Purpose of a constructor

To create an instance of an object from a class

New cards
robot