Category mistake

stackexchange
https://softwareengineering.stackexchange.com/questions/316507/what-is-the-correct-oop-relation-between-complex-and-real-numbers


 * @KevinMills math is very different from programming here in the sense that math objects are immutable. In the context of programming, establishing relation between real and complex numbers would be rather "a category error or category mistake" as was pointed in this answer to similar (possibly diplicate) question – gnat Apr 22 '16 at 12:16

Domain driven design
https://stackoverflow.com/questions/1222392/can-someone-explain-domain-driven-design-ddd-in-plain-english-please/1222488#1222488


 * https://en.wikipedia.org/wiki/Identity_(object-oriented_programming) "..Identity allows the construction of a platonic ideal world, the ontology or conceptual model, that is often used as basis of object-oriented thinking ..."

Which is meaningless nonsense. Stuffing the hash table with the functions in a struct(class), doesn't give you "rock" based thinking but an ontological state of noun reification.

https://en.wikipedia.org/wiki/Domain-driven_design

Herman Peeren
http://hermanpeeren.nl

https://groups.google.com/forum/#!topic/dddcqrs/X3v_b7lxOak

https://groups.google.com/forum/#!topic/dddcqrs/TbzX5OxpNSM

https://groups.google.com/forum/#!topic/dddcqrs/Icep9ujRllk Yes, I see something fundamentally wrong in our beloved concept of Value Objects: there is a category-mistake. That is an indication of a logical error. I'm still investigating the consequences of that and how we can improve our language and thereby our models by avoiding that mistake. This is work in progress.

But I also understand where Value Objects came from and what the merits of the concept was. DDD was a fresh wind in the merely technical modelling practice of those days.The core message of DDD was to focus on the domain, not on general technical terms and that is still a splendid advice. We mainly used ERD's and UML-diagrams in that time. It was very common to model everything as an entity (corresponding to a relational db-table), which gave huge highly integrated object graphs; accidental complexity at its top. Trying to dissect this mess and reduce this complexity, DDD came with practical 'design patterns'. One of those patterns was Value Objects: some objects in your domain don't need an identity-property, because they represent a value and can be replaced instead of updated. In our OOP-languages everything is an object (or mostly: everything is defined as a class and instantiated as objects). The Value Object pattern showed that there are objects where we can leave out the identity-property and just take a new one instead of updating its value. That was a simplification that greatly helped to reduce complexity.

The category-mistake of seeing domain objects as either entities or value objects already was in our models before we used the concept of value objects: when we modelled both the whole and the parts as entities, we already made the same mistake, but it was not visible yet. We didn't see the mistake because we were used to thinking in relational calculus, where everything is a tuple (a relation or table); that has greatly influenced our OO-thinking, where everything is an object, all of the same category. By making the distinction between Value Objects and Entities however, we started to make a distinction between two different categories of objects. By explicitly making two categories of objects, the category-mistake became visible.

When we can use a more elaborate and expandable type system for our values, then we don't need Value Objects. We can then say that something has some price, weight, time, etc. and both the quantity (number) and quality (currency, measure, etc) are part of that value. Those types describe what kind of value something is. That is what I meant by "value objects are just values": if you can only use classes/objects to type a value, then those objects are not the same category of objects as entities, but they are of the same kind as primitively typed (integer, string, etc) values. If a car is red, then its colour-property is the colour red; if a product costs 5 euros, then its price-property is 5 euros; if someone weights 65 kilograms, then her weight-property is 65 kilograms. So, in my model I don't have a car-object and a colour-object, not a product-object and a price-object, not a person-object and a weight-object, but a car, a product and a person with properties that have specific values (of some type). Of course, when implementing this in a computer language where the only way to specify the types for those values are classes/objects, then I have no other choice but to use Value Objects for those types. But those value objects are still nothing else than values.

My quest is to figure out what errors (if any) in our models are the result of the category-mistake of splitting domain-objects in Entities and Value Objects, how we can avoid those errors and so improve our models, without throwing the baby out with the bathwater.That is also why I emphasised the merits: we must keep the good things. This is still work in progress. Until now the main thing I learned from it is, that models are simpler when you don't put things from different categories together, but split it up in your models. Make a different diagram (or event storming session or other ways to model) from a whole and parts/aspects. Interestingly, categories don't have to be mutual exclusive; they can be orthogonal. Also see Christopher Alexander's "A City is not a Tree". That (implicit) complexity can only be unraveled by modelling per category. All sounds pretty theoretical, huh? I am looking for practical examples to illustrate this. To be continued, but then concrete; I promise.

links
oop

Noun, Nouns and verbs oop