S01 Programming Concepts

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

1/42

flashcard set

Earn XP

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

43 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

Encapsulating the aspects of code that are prone to change so that they can be made independently to the rest of the system

21
New cards

Benefits of Encapsulate What Varies

  • Reduces coupling between different parts of the code

  • Improved maintainability by isolating changes

  • Enhanced flexibility via easier ability to extend the system

22
New cards

Coupling

Degree of interdependence between software modules

23
New cards

OOP Principle of Design: Favour composition over inheritance

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

24
New cards

Benefit of Favour Composition Over Inheritance

  • Composition leads to loosely coupled code, where changes in one class have minimal impact on others

  • Greater flexibility as you can change the behaviour of a class at runtime by swapping out components

25
New cards

OOP Principle of Design: Program to interfaces not implementation

The code depends on abstract interfaces rather than specific class implementations. This promotes flexibility, allowing different implementations to be substituted without modifying dependent code, improving maintainability and scalability.

26
New cards

“Program to an interface” (OOP Design)

Should write code in a way that it depends on abstract classes rather than concrete implementation

27
New cards

“Not to an implementation” (OOP Design)

Your code should not directly rely on specific classes or their detailed implementations, which can change or become less flexible over time

28
New cards

Benefits of Program to an Interface, Not to an Implementation

  • Flexibility: programming to interfaces means your code remains decoupled from specific implementations. Can easily swap out or replace one implementation with another

  • Maintainability: it’s easier to make changes to the implementation without affecting the clients of the interface

  • Testability: easier to create mock implementations for unit testing

29
New cards

Recursive techniques

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

30
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

31
New cards

What is stored in the stack frame at every subroutine call

Values of all local variables, parameters and return address

32
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

33
New cards

Variable

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

34
New cards

Constant

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

35
New cards

Advantages of a constant

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

36
New cards

Function

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

37
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

38
New cards

Local variable

Variable that is visible/accessible only to the current subroutine

39
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

40
New cards

Global variable

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

41
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

42
New cards

Why are meaningful identifier names important?

Faster debugging, maintainability, collaboration, enhanced readability, reusability

43
New cards

Advantages of named constants

Readability, maintainability, consistency, protection against accidental changes