00 history Flashcards
programming paradigm
the way you structure code based on the what you are programming
types of programming paradigms
imperative, structured, procedural, object-oriented, functional, event-drive, declarative, automata-based
imperative paradigm
step by step instructions that the computer follows, most basic form
direct assignments, common data structures, global variables
example of imperative paradigm
fortran, c, java, python
structured paradigm
style of imperative with more readable/reusable code, bans goto and enforces function/block
structograms, indentation
example of structured paradigm
c, java, python
difference between imperative and structured
imperative -> loops, conditionals
structured -> functions, blocks
procedural paradigm
reusable how to -> functions
helper functions and main logic
multiple small functions
example of procedural
python
is procedural a type of structured which is a type of imperative
yes
object oriented paradigm
data -> objects that change through predefined methods only
encapsulation, polymorphism, inheritance
related to procedural
example of object oriented
java -> classes
using getter methods to modify class objects in main
functional
declarative -> what instead of how
filters data, immutable: data flows through the pipeline
related to declarative
example of functional
erlang, elixir
event driven
code executes in response to events
(mouse clicks, timer interrupts)
related to procedural and dataflow
example of event driven
javascript, GUI button, main loop, event handlers, asynch processes (timer)
declarative
defines program logic but not control flow -> specify WHAT not HOW
example of declarative
SQL query
automata based
programs -> model systems as state machines
related to event drive and imperative
example of automata
network protocols
fortran
formula translator
cobol
common business oriented language
LISP
List processing
first functional PL
BASIC
beginners all-purpose symbolic instruction code
interactive shell user interaction -> for non stem students
spaghetti code
no clear structure –> code that is hard to read and understand
if you follow code, it resembles spaghetti
example of spaghetti code
deeply nested conditionals, assembly, fortran
what programming was a direct response to the issue of spaghetti code?
structured programming
how did this program help prevent spaghetti code?
code executes line by line
if else/switch for branching instead of goto
iteration -> for/while loops
single in single out: functions have one clear start and end
structured program theorem
all computable functions can be computed with 3 single in and out control flow structures:
1. sequence (statements executed in order)
2. selection (if/else for branching)
3. iteration (while/for for loops)
4 pillars of why OO
encapsulation
polymorphism
inheritance
abstraction
polymorphism
access objects of different types through same interface
each type has own implementation of interface methods ->
static: lets you have methods with same name and different parameters -> determines which one to call based on parameters
dynamic: subclass overrides superclass method -> method overriding
encapsulation
makes attributes and methods work as class while protecting attributes
*car -> car runs, and user uses steering wheel, brake, gas etc without knowing how the car works
inheritance
allows there to be class hierarchy -> classes can extend other classes and inherit those methods -> parent child classes
abstraction
hiding complex implementation details and showing essential parts of object to simplify user interaction