Programming Paradigms Flashcards
What are the 6 paradigms
Imperative
Procedural
Object-oriented
Event-driven
Declarative
Functional
Define imperative programming
-changes the program state by executing a series of commands
-e.g. using varibales to store and iterations
Define procedural programming
-related to imperative programming
-organises code into functions which has a sequemce of instructions
-the program is divided into smaller functions that return values
Define object-oriented programming
-subordinate of imperative programming
-creates resuable methods and classes
-code is more maintainable
What are the 4 principles of object-oriented programming
Encapsulation - binds data and keeps it protected by making the data private within their methods
Inheritance - allows child classes to take charactersitics from a parent class
Abstraction - hides complexity and only shows relevant info
Polymorphism - the same code structure can be used in different forms
Define functional programming
-building software with pure functions
-output is returned based on input given with no reliance outside of the function
-
Give an example of functional programming
using the square function as there is always the same output for the same input (always a squared number)
Define event driven programming
-programs that respond to events or user interactions
-involves real time response
-start - initialise - wait for event
Define declarative programming
-programmer specifies result and program solves how to achieve it
-e.g HTML/CSS