3.3 Programming Paradigms Flashcards
What is a programming paradigm
A style or way of programming
Imperative programming
- Languages which support imperrative programming consist of series of instructions that tell the computer what to do with the input in order to solve the problem
- Procedural programming is imperative programming with procedure calls
Structured programming
- A kind of procedural programming paradigm which uses the constructs sequence, selection and iteration and recursion rather than goto statements
- Modular techniques are used to split a large program into manageable chunks
Declarative programming
Programming where you write statements that describe the problem to be solved, and the language implementation decides the best way of solving it (SQL)
Logic programming
A form of declarative programming which expresses the logic of a computation without expressing its control flow. They mostly consist of logical statments
Backtracking
Backtracking goes back to the last decision point and try another route until either the goal is achieved or there are no further routes to try
Backtracking is important feature of declarative programming
Applications of declarative programming
It is useful for programming expert systems, which embody the facts and rules about a particular field of knowledge
It is also useful for processing natural language
OOP
- OOP was made because to abstract details of implementation away from the user
- The code is designed to be reusable and easy to maintain
- Mainly takes over procedural programming
Features OOP
- Thinking about different methods that the object can represent, for example required tasks
- They also can have different attributes specific to that object
- Data items are called ‘objects’, where objects are instances of the class
Encapsulation
Attributes are usually only classified as private, so only public methods can only be used as getters
Information hiding
The object’s attributes are hidden, and they can only changed or accessed through the object’s methods
What are methods used for
To set setters and retrieve getters are used in order to get an object’s attributes.
In order to interact with an object, its methods must be accessible (public)
Inheritance
- Used when objects are related to other ones in some type of way.
- Each class may even have their own attributes and methods to something that was also inherited from a super class
- The subclass has the same attributes as the the superclass
Polymorphism
- An inherited class may have methods and attributes that do not exist in the parent class
- Polymorphism refers to subclasses adopting different methods (many different ways of doing the same thing specific to that class)
Functional
Functions are used as the fundamental building blocks of a program
- Statements are written as a series of functions which accept input data as arguments and return and output