OBJECT-ORIENTED PROGRAMMING AND ARISTOTLE
Author: Oğuzhan KARAGÜZEL ·
The title might sound a bit intriguing. Personally, like any developer stepping into the world of object-oriented programming, I felt there was a simple yet beautiful philosophy underlying it all.
But don't worry, I'm not here to give you another standard OOP lecture like everyone else. If you're curious about the core logic but can't figure out where to learn it, I'll point you straight to the source. I'll give you a bit of background on it and leave the rest up to you.
Just a heads-up, though: I'll be going into quite a bit of detail about this source. You can either read through it, or just jump straight to the source itself.
ARISTOTLE — CATEGORIES
When you read Aristotle’s Categories carefully and truly absorb it, you might realize that the actual inventor of object-oriented programming was Aristotle himself.
Here is what you need to know to get started: Depending on the translation you read, you might encounter the term "substance" (töz) or "entity" (varlık). They refer to the same thing. However, since their philosophical meaning is a bit different and more nuanced than the "entity" concept you're familiar with in software, the term "substance" became the preferred word over the years.
One thing that might catch your eye—and maybe even confuse you—is that back in those days, colors were treated as physical bodies. You’ll understand what I mean when you read it.
If you want to go straight to the source, here are the books I recommend:
You can read Categories directly. I had picked up a fantastic copy from İmge Yayınları. It might still be on the market:
Aristoteles. (2002). Kategoriler (2. b.). (S. Babür, Trans.) Ankara, Turkey: İmge Kitabevi Yayınları.
Alternatively, you can check out Sir David Ross’s book, Aristotle. It covers Aristotle’s life and explains all of his known works in detail. Prof. Dr. Ahmet Arslan’s Turkish translation is an excellent resource. By reading the "Logic" section in that book, you'll effectively be reading the source I'm talking about:
ROSS, D. (2011). Aristoteles (1. b.). (A. Arslan, Trans.) Izmir, Turkey: Kabalcı Yayıncılık.
Now, my advice is to hear me out a bit before you dive into the reading. That is, if you've never dabbled in philosophy before! If you have, you'll breeze right through it. But it's pretty obvious that anyone without a philosophy background (just like me) will need a little help grasping it (just like I got help from my lovely wife). So, let me give you some brief explanations to at least point you in the right direction.
(IN BRIEF) UNDERSTANDING ARISTOTLE
When you first dive into the books I mentioned, the first thing Aristotle will introduce to you is the categories. Understanding these categories is pretty straightforward. If you ever hit a part you don't get, you can easily figure it out just by rereading it or discussing it with someone. My real goal here is to explain the parts I suspect might trip you up, or the exact moment you catch yourself asking, "So where exactly does object-oriented programming fit into all this?" To make sense of it, let's do a quick intro right from the very beginning. Early in the book, you'll read Aristotle stating the following:
"When one thing is predicated of another as of a subject, everything that is said of the predicate will also be said of the subject. For example, 'man' is predicated of the individual man, and 'animal' of 'man'; therefore 'animal' will also be predicated of the individual man, since the individual man is both 'man' and 'animal'."
As we can see, Aristotle is speaking directly about inheritance here. What is called a "thing" here is actually a substance. Of course, this may be somewhat debatable, since it would be hard to say that Aristotle was consistent about the number of categories. You will see this when you read the book.
Suppose the thing here is me. Everything that is said of "man" will now be said of me as well, because "man" has been predicated of me, the subject. Likewise, everything that is said of "animal" will be said both of me and of "man", because "animal" is predicated of "man", and "man" is now the subject of "animal". And I, as Oğuzhan, am the subject of "man". Therefore, I am also the subject of "animal".
public class Animal
{
}
public class Man : Animal
{
}
Man oguzhan = new Man();
You might be a little confused here. "oguzhan" is a reference-type variable. It points to a Man object. Shouldn't we create a class called "Oguzhan" and produce an instance from it? This is something we can debate among ourselves. Aristotle gives some hints about this topic as well. And of course, you can make this more meaningful by adding more fields.
Now let's continue reading and see what Aristotle has to say to us, and confuse our minds a little more.
A substance, in the strictest and primary sense of the word, is that which is neither said of a subject nor present in a subject, for example, an individual man or an individual horse. Those substances in which the primary substances are found, as species, are called secondary substances, together with the genera of those species. For example, an individual man belongs, as a species, to "man", and the genus of that species is "animal". So these, "man" and "animal", are called secondary substances.
It took me quite a long time to fully grasp these lines. In fact, they are quite simple, but the language used naturally makes them hard to understand. In short, Aristotle is saying the following:
"Oğuzhan" is a substance. He is a substance by virtue of the "man" and "animal" that are predicated of him, or that he inherits (we could even take this further, to matter and from there to energy). But "Oğuzhan" is a primary substance. Or, dear reader, you are a primary substance. We understood that we are substances. But why are we primary substances? Good question! Aristotle answers it: I am neither said of a subject nor present in a subject.
If you are wondering what this means, let me put it this way: the "man" object is said of the "oguzhan" object and is present in it. The "animal" object is in the "man" object, and "animal" is also said of "man". For this reason, "man" and "animal" are secondary substances. But you cannot say of any other object that it "is Oğuzhan". Suppose there were a substance that had all the properties of "Oğuzhan", that is, one that inherits from Oğuzhan and adds its own distinguishing characteristics on top. In that case, "Oğuzhan" would become a secondary substance. But if no substance inherits from Oğuzhan, then Oğuzhan is a primary substance.
I understood this topic more easily through code, so perhaps explaining it to you with code will make it easier. If we examine the case where Oğuzhan is not a primary substance:
public class Animal
{
}
public class Man : Animal
{
}
public class Oguzhan : Man
{
}
public class Substance : Oguzhan
{
}Here, an object derived from the "Substance" class is called a primary substance. In that case, even an object derived from the "Oguzhan" class would be a secondary substance.
So far we have learned the following: since the "Oğuzhan" object is a substance, it must definitely be defined as a class. This is reasonable. While Oğuzhan is a programmer, another person may not be a programmer but an artist. While Oğuzhan cannot show an artist's traits, an artist cannot show a programmer's traits. From here we can arrive at the concept of encapsulation. But it is still too early. In fact, so as not to spoil the excitement of the book, I won't go into this topic and will leave it to you. In the following pages, you will understand it better.
Now, let's return to the main subject. Since "Oğuzhan" is a primary substance, the code block above is wrong. How do we fix this? Like this:
public class Canli
{
}
public class Insan : Canli
{
}
public sealed class Oguzhan : Insan
{
}The sealed keyword says that a class cannot be inherited from. In that case, we can say that an object instantiated from the "Oguzhan" class is a primary substance. Of course, I know you have tons of questions in your mind. Let's take it step by step:
Every substance seems to signify a certain thing directly. As for primary substances, it is beyond dispute that each of them signifies a certain thing directly, since what is indicated was explained to be indivisible and one in number. Secondary substances, because of the form of their names (when we say "man" or "animal"), give the impression that they also signify a certain thing directly, but this is not true. Rather, they signify a quality, since the subject is not one as in the case of the primary substance: "man" or "animal" is said of many things. On the other hand, they do not signify a quality in the absolute sense, like "white", because "white" signifies nothing other than a quality, whereas species and genus mark off the quality with reference to substance, showing what kind of substance it is. The determination made by the genus has a wider extent than that made by the species, since whoever says "animal" indicates something of wider extent than whoever says "man".
Here, Aristotle says that secondary substances do not signify a certain thing but a quality. In that case, as you would expect, we will clearly make use of the abstract keyword. Besides that, we said that primary substances, being substances, are classes. But we also learned from Aristotle that a primary substance signifies a single, indivisible thing, so evidently we should follow the singleton design pattern here. However, I think the following still holds: if we arrange the Man class appropriately, each instance created from Man will refer to its own unique object, so our earlier examples remain correct. In other words, we don't necessarily have to draw the conclusions above from this. But whatever we conclude, it clearly has a place in object-oriented programming. If we rearrange our code:
public abstract class Animal
{
}
public abstract class Man : Animal
{
}
public sealed class Oguzhan : Man
{
private static Oguzhan oguzhan;
private Oguzhan()
{
}
public static Oguzhan GetObject
{
get
{
if (oguzhan is null)
{
oguzhan = new Oguzhan();
}
return oguzhan;
}
}
}Now we have exactly one Oğuzhan. Objects cannot be instantiated from the Man and Animal classes, and Oğuzhan can point to only a single object. We have agreed with Aristotle quite well. As I said, if we arrange the Man class appropriately, every instance we create will logically fit this situation too. So however we choose to draw our conclusions, it has a place in OOP. But I followed this path in order to get into both design patterns and the concept of encapsulation, and to draw the most out of what Aristotle says. Otherwise, even in this case:
Insan oguzhan = new Insan();Since the oguzhan variable refers to only a single object, and there is no question of it being inherited from, there is no need for the singleton design pattern or for encapsulation. But as I said, wherever you take this from here, it has a place in OOP.
So as not to make this article any longer, and so as not to spoil the excitement of the book, I'm ending it here. Honestly, I took great pleasure in discovering this book. (Yes! While reading it, you feel like you are discovering OOP.) I hope you read it with the same excitement and pleasure.
Happy reading.
Finally, object-oriented programming was born out of a need. This need arose from programmers writing code in the C programming language using structs to follow a path much like the one in OOP. As a result, OOP was developed. However, the logic of OOP differs from one programming language to another. It is clear that the basic philosophy was laid out by Aristotle. Furthermore, Microsoft has applied this philosophy quite well with C# and .NET. If you like, you can research the C programming language and structs and learn more about OOP.

