Programming Techniques Flashcards
Sequence (program construct)
Statements executed 1 after another
Selection (program construct)
Statements executed based on conditions
Iteration (program construct)
Count controlled- executed for fixed no times
Condition controlled- until condition met
Encapsulation
Local variable means subroutine is self contained
Used independently
Or in OOP
State, method and attributes encapsulated to 1 entity
Attributes set to private, only accessed and changed by public methods
Features of IDE
Code editor, error diagnostics (breakpoint, stepthrough, set a watch on a variable), run time environment, translator and auto documentation
CERTA
Recursion
Subroutine calls itself Stopping condition \+ Shorter than iteration - If recursion is too long, stack over flow (run out of memory)
Object Orientated Programming
Attributes
State
Behaviours (actions)
Class (template for object, defines a + b)
Constructor
Creates object in class
Instantiation
Instances of class made, shares methods and attributes
Inheritance
Class inherits data and behaviour from parent class
Derived class is sub class
Polymorphism
Same code for different objects but they are processed depending on their data types and attributes Parent class can have 1 method and will have different results depending on which sub class it’s used on
Procedure vs Function
Both take parameters and perform tasks
Procedure does not necessarily return value but function always does
Passing parameters + definition
By value: actual value passed to subroutine
By reference: the address and not value is passed to subroutine
Variable that allows for passing data between functions and procedures
Pass by reference vs by value
Changes in memory vs changes copy of value
A* vs Dijstras
A* uses heuristics
Help solve problem faster
Estimated distance from final node
Doesn’t need to find all possible solutions only searches for path based on lowest current distance travelled