1/8
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced |
|---|
No study sessions yet.
Programming Paradigms
A style or approach to writing and structuring code, defining how problems are solved and how the program is organised.
Turing Complete
A programming language is Turing complete if it can be used to simulate any Turing machine, meaning it can perform any function that a computer is theoretically capable of.
Most modern programming languages are Turing complete.
The use of different paradigms
Different programming paradigms are chosen to suit the problem type, enhance code quality, and make programs easier to maintain and understand by providing clear principles and structures for writing code.
Procedural Programming
Code is written as a sequence of instructions executed step by step.
Code is organised into procedures (functions or subroutines), each performing a specific task.
Focus is on actions or procedures rather than objects or data.
Advantages
Structured approach: Code is organized into procedures, improving readability and comprehension.
Reusability: Procedures can be reused in multiple parts of a program.
Ease of debugging and testing: Step-by-step execution simplifies error detection.
Ideal for simple, sequential tasks: Best suited for straightforward problems.
Disadvantages
Difficult to maintain for large programs: Managing numerous procedures becomes complex as code grows.
Not ideal for complex or real-world problems: Harder to model objects and their relationships.
Limited reusability across projects: Procedures often depend heavily on program context.
Object-Oriented Programming
A programming paradigm where programs are structured around objects that contain data (attributes) and methods (functions).
OOP emphasizes modeling real-world entities, code reusability, and encapsulation through principles like inheritance and polymorphism (using objects interchangeably through shared interfaces).
Advantages
Modularity: Code is organized into objects, making it easier to manage and understand.
Reusability: Classes and objects can be reused in multiple programs.
Encapsulation: Data and methods are bundled together, protecting internal state.
Abstraction: Implementation details are hidden, allowing focus on high-level design.
Inheritance: New classes can reuse and extend existing code.
Polymorphism: Objects of different types can be used interchangeably through shared interfaces.
Better modeling of real-world problems: Objects represent real-world entities, making programs more intuitive.
Disadvantages
Complexity: Designing objects, classes, and relationships can be more complicated than procedural code.
Slower performance: Extra layers of abstraction can lead to slightly lower execution speed.
Larger program size: Object structures can increase memory usage.
Steep learning curve: Understanding principles like inheritance, polymorphism, and encapsulation can take time.
Overhead for small/simple programs: For straightforward tasks, OOP can be unnecessarily complicated.