1.4 principles of programming Flashcards
what is a class (IN OOP)
a template defining methods and attributes used to make objects
inheritance
when a new class is created that is based on another class and it can take the methods and attributes of the parent
protected
only be accessed by methods in the class and these can be inherited (#)
private
can only be accessed by methods in the class but these can’t be inherited
why is BNF preferable to ordinary English when defining the syntax of a computer language
it is unambiguious
what is the purpose of BNF
is used to describe (unambiguously) the syntax of a programming language
explain the purpose of programming paradigm
- a programming paradigm is the structure and approach of a programming language
- many different types which are all aimed at solving different programming problems
- these programming languages include sequence commands such as print and input and iteration constructs such as IF and While (unsure on this point)
examples:
procedural
object-oriented
what is a procedural language
- they are executed sequentially and are composed as a series of programming commands and constructs executed on after the other
- it is a imperative language because the programmer controls the flow and state of the computer programming
when are procedural languages used
- when implementing algorithms as they are programmed linearly, they are not suitable for GUI based problems given the event driven nature of these applications
- they are used in traditional programming based o algorithms or a logical step by step process for solving a problem
- used in large (complicated) programs where similar operations may be carried out at varying stages of the program execution
-could be used to write a wide range of programs, such as business applications, stock control, payroll
examples of procedural language
C and Pascal
what is an event driven program
- a form of object-oriented programming which contains objects such as buttons, combo boxes and lists to create a GUI
- uses event listeners to listen for events such as Click or Hover Over to which code can be attached and executes when a specific event occurs
advantage of event driven programming
very effective when an application needs rapid development of a GUI
what is an example of multi-paradigm languages and the advantage of them
- very versatile and can be used in many different ways
example : python
what do compliers translate and what do they do
- high level language into machine code
- they produce a standalone executable file or package
advantages of compliers
- can be executed without the need for the computer to be installed on the destination machine
-the complied application can be distributed to any machine with the OS it was targeted at and it can run multiple times
-protection - source code is not distributed to the end user
disadvantages of compliers
-target a specific platform (eg. IOS or Windows) once complied for this platform, the executable can only be run on that platform
- cannot be complied if they have any errors throughout the source code - this can be difficult to debug without the use of an IDE
examples of complied languages
Java
C++
what do interpreters translate
-one line of the high level source code into machine code line by line
- each line of machine code is executed before the next is translated
-each time the program runs, the code needs to be interpreted again
what must you have to run an interpreted application
the source code
this means the intellectual property is difficult to manage
advantages of interpreters
- crashes at a specific line, meaning it can be easier to de bug
- code can be distributed to machine different OS and platforms, as long as they have installed an appropriate interpreter
do the one about many lines of machine code