Plato and Object-oriented Programming
Object-oriented programming is a programming language paradigm, i.e., a set of rules followed when writing some computer programs, aiming to model entities called objects.
Conceptually, objects are instances of classes defined as having data and methods, data in the form of fields, and methods in the form of procedures. Fields define the attributes and procedures parameterise the behaviour of the object within a system.
The classification of objects is systematised as a taxonomy, often organised hierarchically in a two-dimensional space. In computer science terminology, the taxonomy could be thought of as the tree data structure.
Object-oriented programming, in practice, is often used to model “real-world” (concrete) entities, such as, a machine, library, or buildings.
A useful frame of reference for modelling relations between entities in a system is reductionism, the opposite of holism. Reductionism and holism can be summed up with the statements, the former of reductionism and the latter of holism (perhaps, in relation to another pattern of dichotomous thought, i.e., facticity and transcendence):
“The whole is the sum of its parts.”
“The whole is more than the sum of its parts.”
The reasoning for modelling entities and their relations can help decide what level of emergence to pay attention to and what frame of reference to choose.
Consider modelling clients in a client-relationship system in a B2C (business-to-consumer) context.
A client could have a name and the required contact details, and could do something like make payments.
Here is an example in the scripting programming language, Python:
class Client:
# fields containing the name and address of a client
name = None
address = None
# a constructor to instantiate a client, given a name and address
def __init__(self, name, address):
self.name = name
self.address = address
# a procedure to allow a client to make payments in dollars
def make_payment(self, dollars):
print(self.name + ' has made a payment of $' + str(dollars))
# instantiate an object, i.e., a client,
# and make the client pay an arbitrary amount of dollars
p_sherman = Client('P. Sherman', '42 Wallaby Way, Sydney')
p_sherman.make_payment(100)
Four pillars serve as the foundations of object-oriented programming, some of which can be traced back to roots of Western philosophy from Ancient Greece:
Abstraction
Encapsulation
Inheritance
Polymorphism
Abstraction is the process of hiding the internal details of an object-oriented system. You could conceptualise it as what is “under the hood” of a system.
Encapsulation is the process of “bundling” data and its corresponding methods into units which would be components of a system.
Inheritance is the process of structuring objects into a taxonomy of classes.
Polymorphism is the process of giving classes flexible parameters, in the sense that data and methods of a class are stripped away to its “bare-bones” with the keyword ‘abstract’, to be made “concrete” when instantiated into a child class of the abstract parent class.
This is where,
Plato, the most prolific student of Socrates, and teacher of Aristotle, the chosen tutor of Alexander the Great, and his theory of Forms comes in to draw a bigger picture.
The etymology of polymorphism is of Greek origin and means something like “many shapes”.
Let us take something many of us are familiar with to illustrate this idea — shadows.
Imagine holding a candle in a dark room full of furniture, ornaments, and any other decor you would like. A shadow takes on a form of an object in the room when light makes contact with it. This demonstrates the polymorphous nature of light (at least, on a macroscopic scale) and how it can take the form what obstructs its path.
You could take the initiative to try this as it is a fairly simple experiment. Any portable light source will do, from a mobile phone flashlight to a blow torch. Seeing things with your own eyes could help cement what I am writing about in your own mind.
Here is this behaviour in the object-oriented programming context:
# Python libraries to implement polymorphism
from abc import ABC, abstractmethod
# an abstract class to be instantiated
class Polygon(ABC):
# an asbstract method with no defined behaviour
@abstractmethod
def edge_count(self):
pass
# instances of the abstract class with defined behaviour for its method
class Triangle(Polygon):
def edge_count(self):
print('There are 3 edges')
class Square(Polygon):
def edge_count(self):
print('There are 4 edges')
# instances of the abstract class and their method calls
triangle = Triangle()
triangle.edge_count()
square = Square()
square.edge_count()
The shadows are illustrative of the immaterial nature of the abstractions that can be derived from matter, especially when implementing a concrete example codified as computer code within the paradigm of object-oriented programming. Capturing this flux-like behaviour, in the sense that shadows appear black in varying shades dependent on light sources without any colour, and that we do not perceive shadows through eyesight as more than two-dimensional phenomena when considering geometry.
This is from Plato’s allegory of the cave, in which this idea is illustrated and described in detail. Plato’s illustrative contention is that the shadows, or ideas are not derived from matter, but that matter is derived from the ideas, through a process of illumination, perhaps with illumination being an allusion to learning and education, what Plato drew attention to in his work surrounding these ideas.
This stark dichotomy can be explored in the two schools of thought regarding the philosophy of science, rationalism and empiricism, with the former in relation to idealism and the latter to materialism.
Perhaps, these ideas can be aptly expressed with the following sentences:
The ideas are what truly exists, with illumination the procession of everything so.
Like shadows taking form, reflected by light on everything that is.
With everything that is, in counter to, everything that is not, in the absence of illumination.
From what is perceived to be real to what is known to be true.
From what is known to be true to what is perceived to be real.