Chapter20.1: Programming Paradigms


Programming paradigms: A programming style/classification // characteristics/features that programming language has/uses

Low-level

Modes of addressing Definition
Immediate The operand is the data being used
Direct The operand is the address of the data being used
Indirect The content stored in the content of the operand is the data being used
Relative The address of data being used is the current address add to the operand
Indexed The address of the data being used is the content of the operand added to the content of index register


Imperative

Describe what is meant by imperative programming paradigm

  • A sequence of steps that changes the state of the program
  • The steps are in the order they should be carried out
  • e.g. procedural programming/language
  • Groups code into self-contained blocks // spilt the program into modules
  • … which are subroutines
  • --
  • Imperative languages use variables
  • … which are changed using assignment statement
  • … they rely on a method of repetition/iteration
  • Statement provide a sequence of commands for the computer to perform
  • … in the order written
  • … each line of code changes something in the program run

Object Oriented Programming

A programming methodology that uses self-contained objects, which contain programming statements(methods) and data, and which communicate with each other

Explain what is meant by Object Oriented programming

  • Create classes
  • … as a blueprint for an object // objects are instances of classes
  • … that have properties/attributes and methods
  • … that can be private to the class // properties that can be only accessed by the class’s methods // encapsulation
  • Subclass can inherit from superclass (child and parent)
  • A subclass can inherit the methods and properties from the superclass
  • A subclass can change the methods from the superclass // subclass can use polymorphism
  • Objects can interact with each other

Explain the difference between a class and an object[^1]

  • A class is the blueprint/design/template (from which the object are later created)
  • A class consists of properties/attributes and methods/procedures/functions
  • An object is an instance of a class
  • An object must be based on a class definition
  • Many objects can exists for the same class

Objects:

An instance of a class that is self-contained and includes data and methods

  • Many instances can exists for the same class
  • Must be based on the class definition

Properties

Data and methods within an object that perform a named action

Methods

A programmed procedure that is defined as part of a class

Classes

A template/blueprint defining the methods and data of a certain type of object

Inheritance

Process in which the methods and data from one class, a superclass or base class is copied to another class, a derived class/subclass

Polymorphism

Feature of OOP that allows a method to be defined more than once in a class, so it can be used in different situations

Containment(aggregation)

Defines a one-way relationship / has-a relationship between two classes. In aggregation, the objects can exists independently with each other. ^2

Encapsulation

Process of putting data and methods together as a single unit, a class

Getter

A method that gets the value of a property

Setters

A method used to control changes to a variable

Instances

An occurrence of an object during the execution of a program

Declarative

Program that specify the desired result rather than how to get it

  • Instruct a program of what is needed to done instead of how to do it
  • … using facts and rules
  • … using queries to satisfy goals
  • Can be logical or functional
  • Logical - states a program as a set of logical relations
  • Functional - constructed by applying functions to arguments / uses a mathematical style

[^1]: 9691 w13 32 q4