Alternatives to OOP in D

Peter C peterc at gmail.com
Sun Nov 9 04:06:21 UTC 2025


On Monday, 1 September 2025 at 16:26:15 UTC, H. S. Teoh wrote:
>
> ...
>OOP is useful for certain classes (ha) of problems, but not all, 
>as the OOP proponents would like you to believe

So who exactly are these OOP proponents?

I do not know of any OOP that says all problems can be suitably 
solved using OOP.

That sound's like a mispresentation, designed to disparge either 
OOP or OOP programmers, or both.

The fact is, differenet paradigms solve different kinds of 
problems more naturally.

Consider this problem:
Four boys and three girls are seated in a row at random. What are 
the
chances that the two children at the ends of the row will be 
girls?

Using an OOP paradigm to solve this problem seems like overkill, 
to say the least.

Now consider this problem:
Seven women have 20, 40, 60, 80, 100, 120, 140 apples.
They all sell their apples at the same price per apple.
Each woman receives the same total amount of money.
You need to find the price per apple.

Here, you are allowed to choose either an OOP or a DOD paradigm 
only.

Note, that changing the paradigm, changes both the framing of the 
problem and its solution.

OOP: Will likely frame the problem in terms of characters in a 
story (entities with roles). The solution will put an emphasis on 
identity, relationships, and encapsulated behavior.

DOD: Will frame the problem in terms of numbers in a table (data 
flowing through transformations). The solution will put an 
emphasis on data layout, throughput, and cache-friendly 
processing.

So being able to frame a problem and a solution from the 
perspective of more than one paradigm is extremely advantageous. 
I do not know of any OOP that would disagree with this assertion.

Please stop disparaging OOP and OOP programmers.

Those of us who use OOP use it because the class of problems we 
deal with are best suited to this paradigm.




More information about the Digitalmars-d-learn mailing list