Principles Of Programming Flashcards

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

Define programming paradigms

A

A programming paradigm is the fundamental structure and approach of a programming language

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

Name all of the different programming paradigms

A

Procedural languages

Non procedural languages (iterative)

Event driven programming

Visual programming

Mark-up languages

Object-oriented programming

They aren’t mutually exclusive (multiple can be used for different languages)

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

Procedural languages

A

An ordered set of instructions in a sequence that the computer follows strictly

Logical step by step process

Allows programmer to define precisely each step when performing a task

Allows the programmer to control the steps being carried out by the processor

Could be used for writing a wide range of programs e.g. business applications, stock control, pay roll

Not ideal for GUI based systems which arent best expressed in a linear algorithm

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

Non-procedural languages

A

Allows programmers to specify the results they want without specifying how to solve the problem

Written as a list of facts and rules

Order of the facts and rules is unimportant

The computer can process can process these facts and rules so as to find the solution to a problem

Used to make e.g. AI systems like expert systems

Sometimes used in database interrogation where returning answers are more important than the exact steps required to calculate the result

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

Traditional/classic procedural languages

A

Text based

Program starts running ‘main procedure’ and calls other procedures from there

No problem if developing simple text-based UI

More difficult if designing GUI

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

Event-driven programming

A

Could be text based but usually apart of a visual programming language

Subroutines are written that react to events that occur

E.g. mouse click

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

Visual programming languages

A

Reduced need to traditional programming

Easy creation of GUI objects e.g. forms, buttons, lists etc.

Rapid development of professional looking applications

Languages e.g. visual basic allow GUI to be developed rapidly

Programming is event driven

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

Mark-up languages

A

Such as HTML and XML are not really programming paradigms but are a key part of Web programming

Mark up languages add commands to a text document to add further meaning to the text or to the structure

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

How is bnf written

A

BNF consists of a list of statements defining ‘meta variables’ written between angle brackets <>. The | symbol is used to represent OR. The := or ::= symbols are used to mean “is defined as”.
E.g.:
:= 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9

Do questions on it

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

How are syntax diagrams written

A

Syntax diagrams are an alternative method of describing the syntax of a language. A path is traced from left to right

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

What does object oriented programming entale

A

Uses: identifiers, selection (ifs), iteration(loops), classes, objects, methods and attributes (attribute is also called a property)

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

What is an object in object oriented programming and what 2 things does it consist of?

A

Objects can be created for ‘things’ that the program needs to manage.

E.g. student, stock, alien (in a game)

Consists of two things:
Data fields (attributes) about the object, such as stockID, Description, etc.

Subroutines/Procedures (methods) that can be performed on the object, e.g. AddStock, DisplayQuantitySold, etc.

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

What is encapsulation

A

Collecting all the attributes and methods related to one thing together into a single object rather than having them spread throughout a program

The definition of an object is a class

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

What are protected attributes

A

Can only be used by derived classes( or sub-classes) that inhdrit from the class

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

What are private attributes

A

Are accessible only within the class

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

What is inheritance in object oriented programming

A

Classes can be reused in future programs and objects can be created that inherit attributes and methods from another object

17
Q

What is the parent class also known as

A

The superclass

18
Q

What is the derived class sometimes known as

A

Subclass

19
Q

What are the symbols which represent inheritance in UML diagrams and which ones which

A

(#)denotes a protected attribute or method

(-) denotes a private attribute or method

(+) denotes a public attribute or method

20
Q

What are the advantages of object oriented programming

A

The ability to combine data and the procedures that use the data together in one object is a much more intuitive way of thinking about a problem

Makes the program easier to maintain and understand as the object complexity can be hidden from the program / people who use it: encapsulation

Inheritance- easy to reuse objects in other programs and if necessary create new objects that inherit from other objects without having to recode

21
Q

Natural languages vs computer languages

A

Natural languages are ambiguous I.e. there can be more than one meaning to sentences

Computer languages are designed to be unambiguous the syntax rules of the language

22
Q

Low level languages

A

E.g. assembly language

Has to write software in a computer-centric way, interacting directly with registers, memory locations, etc.

One low level instruction translates into one machine code instruction

Usually translates into less instructions so will run faster. Smaller programs.

Slower and more difficult to program

Uses more cryptic and harder to understand references to memory locations and sections of code

Time to convert is negligible so runs immediately

23
Q

High level languages

A

E.g. java, python etc.

More human-centric, not requiring direct access to (or knowledge of) the internal registers of the processor.

One line of code translates to many machine code instructions

Compiler will generally not translate into as few machine code instructions

Easier to program

Identifiers can be self documenting

Requires compilation before code can be run for the first time

Easier to create modules that can be reused and accessed by other parts of the program

Allows use of powerful commands that can perform quite complex tasks

24
Q

Where will low level languages be used

A

Embedded processors in e.g. washing machines as is small and efficient

25
Q

Why is bnf preferable to ordinary English

A

English is ambiguous whereas bnf is unambiguous

26
Q

What is the purpose of bnf

A

To describe unambiguously the syntax /grammar/ rules of programming / computer language

27
Q

Problems that might be encountered when using a recursive algorithm

A

Could run out of memory (stack space)

Difficult to debug (dry run) if producing incorrect results as it is difficult determining which recursive call produced the error

28
Q

Define rounding

A

The result is given to the nearest value

29
Q

Define truncation

A

Approximation of a numeric data item by ignoring all information beyond a given number of significant figures

30
Q

Why do programmers find syntax diagrams and bnf notation preferable methods for describing the syntax of programming languages compared to natural English

A

-english language rules can be ambiguous which is a problem

-syntax diagrams provide diagram representations which are easy to follow

-BNF definitions can easily be encoded when writing a compiler