In traditional programming, data and the procedures that manipulate it were often isolated, treating data as a passive component. The Object-Oriented (O-O) model revolutionized this by binding data and procedures together into autonomous structures called objects. These objects represent real-world entities that possess their own identity, state, and behavior, allowing them to interact with themselves and others to form complex systems.
The Building Blocks: Classes and Objects
The fundamental distinction in O-O modeling is between a class and an object. A class acts as a construction plan or a blueprint. It defines the shared structure and behavior that all objects of that type will possess.
An object instance (or simply an object) is a specific realization of a class. While all objects of a class share the same structure, each instance exists independently in time and space and holds its own unique values.
Attributes and State
Objects are described by their attributes, also known as instance variables. These represent the structural characteristics of the object. The specific set of values held by an object's attributes at any given moment is known as the object's state.
Operations, Methods, and Protocols
While attributes define what an object is, operations define what an object does. An operation is a service or behavior a class provides. To perform an operation, a specific method must be implemented. A method consists of a signature and a body containing the actual computer instructions.
To interact with an object, you must send it a message. This message must follow a specific protocol, which is the collection of valid message names (signatures) that an object recognizes.
Keep reading for free.
Create an account to finish this reading and make it part of your study routine.
Continue reading freeAlready have an account? Log in
Updated
