1.2.4 Introduction to programming Flashcards

You may prefer our related Brainscape-certified flashcards:
1
Q

Procedural programming paradigm

A

Procedural programming :
- Program in Subroutines (functions and procedures)
- Subroutines carries out defined and specified steps to achieve output (uses sequence, selection and iteration)
- Uses Top down analysis - Break down problem into sub-problems and code in self contained subroutines using local variables and structured code (sequence, selection and iteration within subroutines)

  • Can be applied to wide range of problems and efficient for straightforward tasks.
  • Easy to write and interpret due to clear flow of control.
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 allows for reuse of code
- Polymorphism allows for flexibility of code
- Better coding for part of team – classes distributed between team members
- Less code needed so errors less likely

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 (e.g. Procedural and OOP)

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 (assembly)

A

Low Level languages :
- Uses mnemonics
- One instruction equates to one machine code instruction –> can be much larger than high level. 1:1
- Translated with assembler
- Useful for embedded processors where speed and efficiency important.

Disadvantages :
- Fixed to specific processor architecture – not portable
- but more knowledge needed of processor - longer to code as more complex

Advantages :
- More control over registers- more efficient with CPU resources and direct control of hardware and memory (through addressing modes)
- Potential for very efficient code through optimised low-level operations.

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 method 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 superclass / 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 and object.
- Reduces volume of code needed as can be reused 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 so can further validate inputs
- Objects can only change in intended way - Protects data from accidental changes and reduces chance of errors and inconsistencies due to unexpected changes to attributes.
- Likely fewer issues as the team combines their code .
- improved security

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

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

Paradigm

A

Programming paradigms are established conventions and practices that dictate how computer programs are structured and developed.
- Different problems and tasks suited to different paradigms that have advantages and limitations.