Paper 1 Definitions Flashcards
Advantages of Subroutines (5)
- reduced amount of repeated code
- can concentrate on error fixing certain parts of the code at a time
- multiple programmers can work on the project at once
- once a function is finished the variables are deleted from memory so not so much memory is needed to run the program
- can use recursive methods e.g. sorting data
Process of Stack Frames (9)
- when a routine is called the computer allocated memory in a specialised region of memory called the ‘stack’
- every time a procedure is called by another procedure, a new stack frame for the procedure is pushed onto the stack
- stack frames contain copies of local variables in the parameters section
- the return address’ (variable’s) memory location is stored in the stack frame
- the stack frame stores the routine’s parameters and local variables until the routine ends
- when the routine ends:
- the value is stored to the return address
- control is passed back to the main function
- the stack frame is removed from the stack
2 Types of Programming Paradigms
- types
- descriptions
- examples
Imperative
- “we use instructions to say how to get the output we want”
- Procedural Programming: use subroutines, selection, sequence, iteration
- Object Orientated Programming: use objects and classes
Declarative Programming
- “we say what we want”
- Functional Programming
Advantages of OOP (6)
- data is protected by encapsulation
- an object can be changed without needing to change the objects that interact with it (improved software maintainability)
- class code is reusable
- improved software stability and consistency
- lower cost of development
- higher quality software
Disadvantages of OOP (5)
- harder to produce efficiently
- approach is not suited for all applications
- larger program size
- slower program execution due to increased instruction base
- can be difficult to apply over wide variety of applications
Class (definition)
- a group of objects with the same attributes and methods
- a blueprint to describe how the data type works
- an object definition
Instantiation (definition) (+ what happens)
The process of making an instance of an object
- usual for a constructor to run when an object is created
- this will set the values for the attributes of the object
Encapsulation is applied if (3)
- you need to prevent change to an object from external objects
- the internal complexity is not needed by other object and doesn’t affect their states
- (objects can communicate together but their implementation details are hidden from one another)
Multiple Inheritance (2)
- occurs when a class inherits from more than one parent
- gives more power to an OOP language as many base classes can be set up from which subclasses gain properties
Aggregation (definition)
A relationship between objects/classes where an object/class contains other objects/classes
- “has a” association between objects/classes
- lifecycle of the two objects/classes is independent
- - both exist in their own right (if one deleted the other still remains)
Composition (definition)
A relationship between objects/classes where an object/class contains other objects/classes
- “a part of” association between objects/classes
- life cycle of the object/class is dependent on the other object/class that contains it
- - if you remove the parent object/class then all child objects/classes are removed
Polymorphism (definition)
The ability of a programming language to process objects differently depending on their data type/class
- the ability of a method to exhibit different behaviours depending on the object on which the method is invoked
- allows different classes to be used with the same interface
Hash Table (definition)
Data structure that creates a mapping between keys and values
Dictionary (definition) (data type)
- a dictionary is a collection of key value pairs in which the value is associated via the associated key
- abstract data type
Convex Combination of Two Vectors
- finds a way to calculate points that lie on a line between 2 points
- 𝛂u + ꞵv where
- u and v are vectors
- 𝛂 + ꞵ = 1
- 𝛂 and ꞵ are >= 0