1.2.4

Cards (28)

  • Programming paradigms
    • Imperative
    • Declarative
  • Imperative programming paradigms

    • Use code that clearly specifies the actions to be performed
  • Declarative programming
    • Focuses on stating the desired result rather than the exact series of instructions that need to be performed to get to the result
  • Imperative programming paradigms
    • Procedural
    • Object-oriented
  • Declarative programming paradigms
    • Functional
    • Logic
  • Procedural programming
    One of the most widely-used paradigms, a type of imperative programming which uses a sequence of instructions carried out in a step-by-step manner
  • Procedural programming examples
    • Pascal
    • Python
    • Logo
  • Object-oriented programming (OOP)
    Another popular paradigm, applicable to certain types of problem with lots of reusable components which have similar characteristics, built on entities called objects formed from classes which have certain attributes and methods
  • Object-oriented programming examples
    • Python
    • Delphi
    • Java
  • Functional programming
    Uses the concept of reusing a set of functions, which form the core of the program, closely linked to mathematics
  • Functional programming examples
    • Haskell
    • C#
    • Java
  • Logic programming
    Part of the declarative programming paradigm, uses code which defines a set of facts and rules based on the problem, queries are used to find answers to problems
  • Logic programming example
    • Prolog
  • Procedural languages
    • Use traditional data types such as integers and strings which are built into the language and also provide data structures like dictionaries and arrays
  • Structured programming constructs

    • Sequence
    • Selection
    • Iteration
    • Recursion
  • Assembly language
    The next level up from machine code, part of a family of low level languages, converted to machine code using an assembler, uses mnemonics rather than binary which makes it easier to use than direct machine code, processor-specific as it directly interacts with the CPU's special purpose registers
  • Assembly language mnemonics
    • ADD
    • SUB
    • STA
    • LDA
    • INP
    • OUT
    • HLT
    • DAT
    • BRZ
    • BRP
    • BRA
  • LMC program to find the modulus of num1 divided by num2
    1. INP
    2. STA num1
    3. INP
    4. STA num2
    5. LDA num1
    6. positive STA num1
    7. SUB num2
    8. BRP positive
    9. LDA num1
    10. OUT
    11. HLT
    12. num1 DAT
    13. num2 DAT
  • Addressing modes
    • Immediate addressing: operand is the actual value
    • Direct addressing: operand gives the address which holds the value
    • Indirect addressing: operand gives the address of a register which holds another address, where the data is located
    • Indexed addressing: an index register is used, the address of the operand is determined by adding the operand to the index register
  • Class
    A template for an object, defines the state and behaviour of an object
  • Attributes
    Give an object's properties
  • Methods
    Describe the actions an object can perform
  • Instantiation
    The process of creating an object from a class
  • Encapsulation
    Attributes are declared as private so can only be altered by public methods
  • Constructor
    A special method called when a new object is created
  • Inheritance
    A subclass can inherit from a superclass and possess all of the methods and attributes of the superclass
  • Polymorphism
    Objects can behave differently depending on their class, can result in the same method producing different outputs
  • Types of polymorphism
    • Overriding
    • Overloading