1.2.4 Introduction to programming Flashcards

1
Q

Procedural programming paradigm

A

Procedural programming :
- Can be applied to wide range of problems
- Easy to write and interpret
- Program in Subroutines (functions and procedures)
- Subroutines carries out defined and specified steps to achieve output (uses sequence, selection and iteration)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Object orientated programming paradigm

A

Object orientated : Can develop solution modelled on real world objects.
Advantages:
- Easier to update and maintain due to modular structure and classes can be modified or extended
- Encapsulation limits how attributes can be changed – debugging and security better.
- Improved re-usability of code – classes can be used in other programs and inheritance and polymorphism allow for re-usability
- Better coding for part of team – classes distributed between team members

Disadvantages :
- Where Few components reused - generally inefficient
- Generally Unsuitable for smaller problems

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Machine code

A

Binary code that the computer can execute
Each line Consists of Opcode (instruction) and Operand (data)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

High-Level languages

A

High Level languages :
- Closer to natural language / English –> easy to debug and build in team so faster development
- One instruction in high level can equate to many machine code instructions (one to many)
- Portable - Independent of processor architecture
- Translated with translator to machine code for different architectures.
- More abstracted - no knowledge of processor needed
- Come in many paradigms so can choose for problem.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Low-Level languages

A

Low Level languages :
- Uses mnemonics
- One instruction equates to one machine code instruction –> can be much larger than high level. 1:1
- Fixed to processor architecture – not portable
- Translated with assembler
- More control over registers- more efficient with CPU resources and direct control of hardware and memory (through addressing modes)
- Useful for embedded processors where speed and efficiency important.
- but more knowledge needed of processor - longer to code

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Immediate addressing

A

Immediate addressing: Opcode acts on operand
- Data hard coded into instruction
- Nothing fetched from memory so very fast
- Value fixed at compilation so inflexible

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Direct addressing

A

Direct addressing: Operand is the memory location data is stored in
- Code refers directly to memory address of data
- Fast as RAM quickly accessible
- Flexible as value at address that is loaded can vary
- Limited on address range by size of operand

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Indirect addressing

A

Indirect Addressing : Operand gives address which holds address of where the data is located.
- Often used with libraries that get loaded into memory at run time, loader will likely place in different location in memory each time
- More flexible
- Increased address range as not limited by operand size.
- however multiple fetches required to access data.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Modes of addressing

A

Opcode - Specifies instruction
Operand - Data instruction is to be performed on
Addressing mode specifies how the operand should be interpreted

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Indexed addressing

A

Indexed addressing : Operand is added to contents of Index Register (base address) to get memory location of value needed.
- Good for data that is stored contiguously such as in arrays.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Object Orientated Programming (classes and objects)

A

Classes - Blueprint for object - constructor function instantiates object from class
- Defines attributes and methods implemented

Objects - Instance of a class
- Has attributes and methods tied to instance and not spread out.

Methods - Actions performed by object that link to procedures and functions

Attributes - Value held by object that link to variables

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

OCR Syntax for OOP

A

Class dog()
Private name
Private colour
Public procedure new (MyName,MyColour)
name = MyName
colour = MyColour
Endprocedure

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Inheritance

A

Inheritance : Where a subclass / child inherits attributes and methods of parent class
- Reduces volume of code needed
- Can override methods of parent class and have own methods and attributes

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Polymorphism

A

Polymorphism : Where code can handle objects of different classes in the same way
and they can behave differently based on their class.
- Reduces volume of code needed and code can be more flexible

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Encapsulation

A

Encapsulation: When attribute is private (can only be accessed from within class)
- Only Public methods can be used to read / amend the attributes value.
- Can further validate inputs
- Objects only interact as intended and prevents unexpected changes to attributes having unforeseen consequences.
- Protects data from accidental changes - objects can only change in intended way - reduces chance of errors and inconsistencies.
- Likely fewer issues as the team combines their code .

Create getter and setter methods.
Setter is method that sets the value of an attribute
Getter is method that returns the value of an attribute

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Paradigm

A

A Paradigm is a way of thinking - programming languages come in and support many paradigms.
- Different problems suited to different paradigms that have advantages and limitations.