1.2.4 types of programming language Flashcards
(20 cards)
programming paradigms
style of programming (one/multiple paradigm can exist in a language)
-procedural
-declarative
-OOP
-functional
procedural
sequence of subroutines/instructions called to achieve the result
how to control the flow:
-sequence
-selection
-iteration
-recursion
imperative vs procedural
imperative is under procedural
declarative
state the end result wanted
e.g. SQL
funtional
reusing a set of functions, like function calls; closely linked to mathematics
e.g. Java
assembly language
low level language
-uses mnemonics
-one level up from machine code
-converted to machine code using an assembler
LMC
little man computer :
- uses mnemonics
- processor-specific
instructions:
-LDA
-STA
-OUT
-INP
-ADD
-SUB
-BRA
-BRP
-BRZ
-HLT
-DAT
modes of addressing
-immediate
-direct
-indirect
-indexed
immediate
operand held the value needed to perform the instruction
direct
operand gives the address which holds the value
indirect
operand gives the address that points to another address that holds the data needed
indexed
the sum of the value in operand and indexed register gives the address of the data that is needed
-useful in accessing arrays (and reason for arrays to be stored contiguously in memory location)
OOP
object oriented programming
-program consist of objects, each has attributes and methods
-all processing is done by objects
related terms:
-class
-objects
-attributes
-methods
classes
-blueprint of an object
-defines attributes and methods that capture the common characteristics and behaviours of objects
attributes and methods
attributes: the data
methods: the behaviour of the object
polymorphism
- objects can behave differently depending on their class
- overriding: redefine the methods of the parent class to suit itself
- overloading: passing in a different parameter into the method
ENCAPSULATION
-attributes and methods wrapped onto a single entity
-attributes are hidden(private) and changed only through method
-methods help get and set attributes; methods are public and accessible
inheritance
-relationship among classes where a sub-class shares all of the attributes and methods of a parent class
-inherited class may have methods and attributes that does not exist in parent class
determining the appropriateness of the inheritance:
-is object A an object B?
private and public
encapsulation method
private: make sure attributes cannot be directly accessed and edited by users
methods to manipulate data in OOP
constructor: create an instance of the object
getter: get the data attribute
setter: set the data attribute
-> to prevent users from accidentally changing the data (security and referential integrity?)