Programming Paradigms: Evolution and Key Concepts
Evolution of Programming
Sequential Programming
A sequential program executes instructions in order, one after the other, until completion.
Structured Programming
Structured programming aims for clear code using three structures: sequence, selection, and iteration. It avoids unconditional transfers like GOTO statements.
The Structured Program Theorem (Böhm-Jacopini) states that any program can be written using:
- Sequence
- Conditional instructions
- Iteration (loops with beginning conditions)
Object-Oriented Programming (OOP)
OOP uses objects and their interactions to design software. Key techniques include inheritance, abstraction, polymorphism, and encapsulation. Popular since the early 1990s, OOP differs from structured programming by combining data and procedures into objects. Instead of focusing solely on data processing functions, OOP defines objects that respond to messages.
Event-Oriented Programming
In event-driven programming, the program’s structure and execution are determined by events, either user-initiated or system-generated. Unlike sequential or structured programming, the flow is controlled by external events.
Core Concepts
Instance
An instance is a copy of an executable program loaded into memory. It’s created by user actions (like clicking an icon) or command-line entries, and can even be generated by other programs.
Constructor
Constructors are special methods within objects, activated during object creation. They initialize the object’s properties and define its initial state.
Destructor
A destructor is a method triggered when an object is destroyed. It performs cleanup actions, like releasing resources, before the object’s lifecycle ends.
Subject
A subject is a complex structure for temporary data storage and management, combining attributes (storage space) and methods (administration routines).
Visual Object
A visual object includes attributes (data, graphics configuration, visibility, position), instance methods, and more.
Classes
Classes organize objects into families. Objects within a class inherit common elements. Visual programming models group objects into classes, similar to biological taxonomies.
Principles of OOP
Encapsulation
Encapsulation groups related elements within the same entity, increasing cohesion. It’s often confused with concealment but focuses on logical grouping.
Concealment
Concealment hides internal processes, exposing only necessary functionalities to the programmer. This controls internal operations and prevents unintended interference.
Polymorphism
Polymorphism allows objects of different classes to use the same program element and perform the same operation differently, depending on the object type.
Inheritance
Inheritance allows an object (derived class) to inherit properties, methods, and events from another object (base class), adding or modifying functionalities as needed.
OOP Policies
Message Passing
Message passing involves sending an order (message) to an object, instructing it to perform an action. A message includes the receiving object, the event type, and necessary data.