Principles Of Programming Flashcards
Define programming paradigms
A programming paradigm is the fundamental structure and approach of a programming language
Name all of the different programming paradigms
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)
Procedural languages
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
Non-procedural languages
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
Traditional/classic procedural languages
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
Event-driven programming
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
Visual programming languages
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
Mark-up languages
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 is bnf written
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 are syntax diagrams written
Syntax diagrams are an alternative method of describing the syntax of a language. A path is traced from left to right
What does object oriented programming entale
Uses: identifiers, selection (ifs), iteration(loops), classes, objects, methods and attributes (attribute is also called a property)
What is an object in object oriented programming and what 2 things does it consist of?
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.
What is encapsulation
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
What are protected attributes
Can only be used by derived classes( or sub-classes) that inhdrit from the class
What are private attributes
Are accessible only within the class