S01 Programming Concepts

0.0(0)
studied byStudied by 0 people
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/36

flashcard set

Earn XP

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

37 Terms

1
New cards

Three things that define an object

fields, methods, identifiers

2
New cards

Class

Defines methods and attribute fields that capture the common behaviours and characteristics of objects

3
New cards

Object

Instance of a class

4
New cards

Constructor

Method used to instantiate an object and initialise its attributes

5
New cards

Instantiation

Process of creating an object from a class

6
New cards

Encapsulation

Concept of keeping an object’s data (attributes) and code (methods) within the same unit which is the actual object

7
New cards

Inheritance

Concept where the sub-class can use all attributes and methods from the parent class

8
New cards

Polymorphism

Concept related to inheritance, where a method in the parent class may be redefined to meet the requirements of the sub-class; its identifiers will remain the same

9
New cards

Overriding

Concept linked to polymorphism, in which the redefined method takes precedence over the method with the same name in the parent class

10
New cards

Accessors

Method that allows other objects to obtain the value of instance variables or static variables (getter methods)

11
New cards

Mutators

A method used to control changes to a variable (setter methods)

12
New cards

Association

A relationship between two classes. There are different types of association: composition and aggregation.

13
New cards

Algorithm

A sequence of steps to complete a task that always terminates

14
New cards

Abstraction

The actual method is not supplied in the parent class which means it must be provided in the sub-class. In this case, the object is being used as an interface between the method and the data

15
New cards

Static method

Method that can be used without an object of the class being instantiated

16
New cards

Virtual

A method is defined in the parent class but can be overridden by the method in the sub-class where it will be used. This is a feature of polymorphism

17
New cards

Why is OOP used?

encapsulation, reusability of methods, easier debugging, less error-prone, programmers don’t need to know how the code works, data integrity

18
New cards

Association by aggregation

Concept where one or more attributes inside an object are objects themselves, of other classes; if the container object is destroyed then the contained objects continue to exist

19
New cards

Association by composition

Concept where one or more attributes inside an object are objects themselves, of other classes; if the container object is destroyed, then the contained objects are destroyed

20
New cards

OOP Principle of Design: Encapsulate what varies

Creates as many classes as needed by data/problem

21
New cards

OOP Principle of Design: Favour composition over inheritance

Association is less error prone than inheritance, and enables easier maintenance

22
New cards

OOP Principle of Design: Program to interfaces not implementation

In OOP and interface = methods to be used; when a class is created that adheres to the methods in the interface; when an object is instantiated, it uses this interface because it will use the methods

23
New cards

Recursive techniques

A routine that calls itself for all inputs other than the base case, eventually terminates

24
New cards

Base case

Used to stop the recursion process. When the base case is met the recursion stops and the stack begins to unwind

25
New cards

What is stored in the stack frame at every subroutine call

Values of all local variables, parameters and return address

26
New cards

What is stored in the stack at every recursive call

Values of all local variables, parameters at moment of recursive call, return address

27
New cards

Variable

Memory location, given an identifier and a data type, to store data at runtime

28
New cards

Constant

Memory location, given an identifier and a data type, to store data but can’t change at runtime

29
New cards

Advantages of a constant

Can be referenced anywhere in the code. Better maintenance, only need to change constant value once

30
New cards

Function

Section of code, given an identifier and a data type, performs a task and always returns a valule

31
New cards

Procedure

Section of code, given an identifier, that performs a task and may return a value - if it does, it will be via a parameter

32
New cards

Local variable

Variable that is visible/accessible only to the current subroutine

33
New cards

Advantages of local variables

Easier maintenance of code and debugging; only need to look in the subroutine using the variable that throws and exception, rather than trace the whole program

34
New cards

Global variable

Variable that can be accessed and altered from anywhere in the program

35
New cards

Advantages of a structured approach to design and coding

  • Easier maintenance / debugging of code

  • Testing can be carried out by module before being combined into the overall solution

  • Separate teams can work on the same project, taking over parts of it, and speeding up its completion

36
New cards

Why are meaningful identifier names important?

Faster debugging, maintainability, collaboration, enhanced readability, reusability

37
New cards

Advantages of named constants

Readability, maintainability, consistency, protection against accidental changes