3 - Programming Paradigms/OOP

0.0(0)
Studied by 0 people
call kaiCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/19

flashcard set

Earn XP

20 Terms

1
New cards

What is a programming paradigm?

A programming paradigm is a fundamental style of writing computer code, which contains a framework for how data should be organised/designed.

2
New cards

What does ‘Turing complete’ mean?

When a language can solve all problems a computer can.

3
New cards

What is the order of low level languages?

Hardware → Machine Learning → Assembly

4
New cards

What is the difference between ML and assembly?

ML: Binary, closest to what happens on a computer

Assembly: Mnemonics

5
New cards

What do high-level languages involve?

One instruction = Many lines of code

More complex

Similar to human speech

6
New cards

What are the two types of high-level languages?

Imperative

  • Uses statements to change a program’s state via sequence, selection, and iteration.

  • Sub-divided into procedural (built on subroutines) and object-oriented (more modular)

Declarative:

  • Focuses on what the program should achieve.


7
New cards

What are the characteristics of OOP and procedural programing?

Procedural:

  • Seq, selection, iteration

  • Stored in variables

  • Subroutines

  • Expressed in procedure calls

OOP:

  • Seq, selec, iteration, inheritance, encapsulation, etc…

  • Stored in attributes

  • Expressed in classes, methods, and instances

  • Based on purpose, not what it holds


8
New cards

What is problem decomposition?

Breaking a larger problem into smaller problems to produce a hierarchy chart.

Each smaller module should become a subroutine.

9
New cards

Advantages of problem decomposition/hierarchy charts:

  • Understandable: clear purpose

  • Reduces bugs and errors

  • Maintainable: one change doesnt change all

  • Collaboration

  • Portabiltiy

  • Reusability


10
New cards

Definition of OOP

An imperative programming paradigm that involves the capturing of information and code into objects.

They are responsible for their own data and the actions performed upon it.

11
New cards

Class versus object?

The class is the blueprint, which is adapted with specific attributes to become an object.

Example: Class = car, object = Mercedes

12
New cards

What is instantiation?

The process of creating an object from a class template.

13
New cards

What is inheritance?

When code is re-used from one class to another without affecting the original attributes.

14
New cards

Superclass vs subclass?

Superclass: The original attributes

Subclass: The extended attributes

15
New cards

What is encapsulation and why is it done?

The process of bundling data and methods in order to restrict access to it.

This is done to:

  • provide privacy

  • hide internal complexity

  • restrict altering of the object from elsewhere


16
New cards

Static vs dynamic polymorphism?

Static: Allows methods in the same class to have the same name, as long as they have different parameters.

  • Parameters can be different by amount, type, and colour

Dynamic: Allows methods in the same class to have the same name AND same parameters.

  • Provides different functionality depending on whether they’re implemented by the superclass or subclass.


17
New cards

Two types of association and their symbols.

Aggregation (outlined diamond) and composition (solid diamond)

18
New cards

What is aggregation?

A weak type of association, where a class is a ‘container’ of other classes.

  • Contained classes hold little dependency

  • Still exist if the container is destroyed.

Example: Head teacher and teacher


19
New cards

What is composition?

A stronger type of association, where a class is a ‘container’ of other classes.

  • There is high dependency on the container

  • If it is destroyed, so are the contained classes.

Example: Building and a room


20
New cards

What are the three OOP design principles?

  1. Favour composition over inheritance (flexibility)

  2. Encapsulate what varies; methods should be subdivided as much as possible into potential subroutines.

  3. Program to an interface not implementation. The programmer should focus on the code’s purpose, and not how it works.