Interesting.
You may also be interested in looking at the Law of Demeter.
Another thing you may be interested in is c2's FearOfAddingClasses, as, arguably, the same reasoning that lead programmers to denormalise databases also leads to god classes and other code smells. For both OO and DB normalisation, we want to decompose everything. For databases this means more tables, for OO, more classes.
Now, it is worth bearing in mind the object relational impedance mismatch, that is, probably not everything will translate cleanly.
Object relational models or 'persistence layers', usually have 1 to 1 mappings between object attributes and database fields. So can we normalise? Say we have department object with employee1, employee2 ... etc. attributes. Obviously that should be replaced with a list of employees. So we can say 1NF works.
With that in mind, lets go straight for the kill and look at 6NF database design, a good example is anchor modelling, (ignore the naming convention). Anchor modelling/6NF provides highly decomposed and flexible database schemas, how does this translate to OO 'normalisation'?
Anchor modelling has these kinds of relationships:
- Anchors - unique object IDs.
- Attributes, which translate to object attributes: (Anchor, value, metadata).
- Ties - relationships between two or more objects (themselves anchors): (Anchor, Anchor... , metadata)
- Knots, attributed Ties.
Attribute metadata can be anything - who changed an attribute, when, why, etc.
The OO translation of this is looks extremely flexible:
- Anchors suggest attribute-less placeholders, like a proxy which knows how to deal with the attribute composition.
- Attributes suggest classes representing attributes and what they belong to. This suggests applying reuse to how attributes are looked up and dealt with, e.g automatic constraint checking, etc. From this we have a basis to generically implement the GOF-style Structural patterns.
- Ties and Knots suggest classes representing relationships between objects. A basis for generic implementation of the Behavioural design patterns?
Interesting and desirable properties of anchor modelling that also translate across are:
- All this requires replacing inheritance with composition (good) in the exposed objects.
- Attribute have owners rather than owners having attributes. Although this make attribute lookup more complex, it neatly solves certain aliasing problems, as there can only ever be one owner.
- No need for Null. This translates to clearer null handling. Empty-case attribute classes could provide methods for handling the lack of a particular attribute, instead of performing null-checking everywhere.
- Attribute metadata. Attribute-level full historisation and blaming: 'play' objects back in time, see what changed, when and why, etc. (if required - metadata is entirely optional)
There would probably be a lot of very simple classes (which is good), and a very declarative programming style (also good).
Thanks for such a thought provoking question, I hope this is useful for you.