What is Object-oriented programming?
Object-oriented programming is a programming paradigm whare programs are made up of what are known as objects.
Some definitions and details
An object holds data and procedures that operator on that data. Data and procedures are collectively called the properties of an object. "Fields" or "attributes" are other names used to refer to data. The procedures of an object are commonly known as methods or operations. Data holds the state of an object and the operations define the behavior of an object.
An operation of an object can be executed by making a request. Such a request is also called a method invocation or a method call. "Sending a message to an object" has the same meaning.
In a pure object oriented system, operations (or methods) are the only way to change the internal data of an object.
Who invokes an operation of an object is called a client. In OOP, one object may call the operations of other objects so the calling object is called a client.
An operation is declared by the operation's name, the parameters it takes and what the operation returns. This is called the signature. The set of all signatures of an object is called its interface. In a broader way, an interface can be described as the contract between an object and its external world.
A programmer write classes to describe the objects. A class is a template or a blueprint from which multiple objects of that type can be created.
Creation of an object from a class is called instantiation. The object created from a certain class can also be referred to as an instance of that class.
Sample code
Click here to view Git repository content
Fundamentals of OOP
Data abstraction
Simple explanation: Writing classes by grouping together related methods and fields is called data abstraction.
More qualitative explanation: A programming technique where a data type is created to hide the details of the data representation.
abstract: not real, conceptual
abstract data type: a mathematical model of a data type that defines a set of values and the operations that can be performed on them, without specifying how the data is stored or how the operations are implemented
abstraction: Process of excluding details not necessary but expose only essential details.
Encapsulation
Allowing the internal state of an object to be changed only via methods. Also known as data hiding.
Inheritance
Getting the properties of a type by another type that have a parent-child relationship.
Polymorphism
Ability to substitute one type for another type that has the same interface at runtime.
Word meaning: having many forms
binding: Association of a request to an object and one of its operations.
dynamic binding: Runtime association of a request to an object and one of its operations.