Structured programming evolved in the 1960s and 1970s. The name refers to the practice of building programs using a set of well-defined structures: Sequence structure defines the default control flow in a program. This structure is built into programming languages. A computer executes lines of code in the order in which they are written. It is possible, as a result of a conditional statement or a function call, that the flow may have the option of going in one of several different directions.
Selection structures are built around the conditional statements. If the conditional statement is true, certain lines of code are executed. If the conditional statement is false, those lines of code are not executed.
Repetition structures (or looping structures) use the loops. In a repetition structure, the program checks a conditional statement and executes a loop based on the condition. If the condition is true, then a block of one or more commands is repeated until the condition is false.
In the 1980s object-oriented programming (OOP) was developed. Many programmers claim that an object orientation is a natural way of thinking about the world and it makes programs simpler and programming faster.
Concepts of object-oriented programming are objects and classes. OOP enhances structured programming. Objects are composed of structured program pieces, and the logic of manipulating objects is also structured. Every object has attributes and functions and may contain other objects. For example, the car object has attributes (color, size, shape, top speed), functions (moves forward, moves backward, opens its windows) and may encapsulate other objects (tires, chassis, drive-train) with their own attributes and functions.
All objects belong to classes. A class consists of attributes and functions shared by more than one object. All cars, for example, have a steering wheel and four tires. All
cars can drive forward, reverse, park, and accelerate. Class attributes are called data members, and class functions are represented as member functions or methods.
Classes can be divided into subclasses. The car class, for example, could have a luxury sedan class, a sports car class, and an economy car class. Subclasses typically have all the attributes and methods of the parent class. Every sports car, for example, has a steering wheel and can drive forward. This phenomenon is called class inheritance. In addition to inherited characteristics, subclasses have unique characteristics of their own (fuel economy, trunk space, appearance).
When an object is created, it automatically has all the attributes and methods associated with that class. In the language of OOP, objects are instantiated (created).
Objects do not typically perform behaviors spontaneously. A car, for example, cannot move forward and backward at the same time or drive forward spontaneously.
You send a signal to the car to move forward by pressing on the accelerator.
Likewise, in OOP, messages are sent to objects, requesting them to perform a specific function. Part of designing a program is to identify the flow of sending and receiving messages among the objects.