Contexts and identity

59 views
Skip to first unread message

Andreas Sƶderlund

unread,
Nov 2, 2022, 3:49:21ā€ÆAM11/2/22
to object-composition
I'm considering an Account that is slightly more sophisticated than one with a number that can be increased/decreased. Closer to reality, this Account comprises a set of Ledgers that are added to when the balance changes, and the balance itself is not a number but the sum of those Ledgers.

What I'm thinking is that we're instantiating a new Account, but it doesn't contain any state, just operations on the Ledgers. This Account object is just a set of Ledgers behind the scenes, which get Role behavior when inside the Account Context. But when comparing identity, the Account is a separate object, not the actual Ledger set. Shouldn't its identity be the ledger set? If not, why so?

I realize this gets problematic when a Context contains multiple roles and state, in which case it's hard to decide what should represent its identity but a new object. But it's an interesting question, what something really is. I like this example with colors, that we have in the history of humanity said that something "is" red. But when technology enabled us to study atoms, we saw that something is onlyĀ perceived as red, as certain atoms absorbs all visible light except for the red frequencies. So what we say "is red" is actually "everything but red", but just as in DCI, we want to "uphold the illusion" with a mental model that works for the user, so we say something is red.

And still, just because an atom interacts with light as observed, behind the scenes we don't know what the atom really is. (As a programmer, I'd say it seems closer to software than hardware at least!)

So back to the question, what can be said about Contexts and identity regarding all this?

Lund Soltoft

unread,
Nov 2, 2022, 9:35:04ā€ÆAM11/2/22
to object-co...@googlegroups.com
If I play a game of D&D with my friends, does that game exist and is it different from the game of D&D Iā€™ll play with my brother in law and his wife tomorrow?

A game of D&D has not physical existence. Itā€™s is merely the interactions that happens between the (role) players. Those interactions are guarded by specific rules.Ā 

Iā€™m fairly certain that we can all agree that the two context of playing D&D mentioned above are different and that both are identifiable. That is to say they both have a unique identity. In two weeks Iā€™ll play a new game of D&D with the same friends. Being a new game but with the same (role) players Iā€™d also posit that the identity is not given by the players.Ā 

Mvh
Rune

Den 2. nov. 2022 kl. 08.49 skrev Andreas Sƶderlund <gaz...@gmail.com>:

ļ»æI'm considering an Account that is slightly more sophisticated than one with a number that can be increased/decreased. Closer to reality, this Account comprises a set of Ledgers that are added to when the balance changes, and the balance itself is not a number but the sum of those Ledgers.
--
You received this message because you are subscribed to the Google Groups "object-composition" group.
To unsubscribe from this group and stop receiving emails from it, send an email to object-composit...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/object-composition/d110102e-b279-4c18-a75b-c0d1cb6ba424n%40googlegroups.com.

James O Coplien

unread,
Nov 6, 2022, 6:19:58ā€ÆAM11/6/22
to object-co...@googlegroups.com


On 2 Nov 2022, at 14.34, Lund Soltoft <lunds...@gmail.com> wrote:

If I play a game of D&D with my friends, does that game exist and is it different from the game of D&D Iā€™ll play with my brother in law and his wife tomorrow?

This is qualitatively different from what Andreas is asking, because your example is a new game every time, whereas the account example is a continuous set of data across time. Forgetting all data is O.K. in your case but not in his.

I'm considering an Account that is slightly more sophisticated than one with a number that can be increased/decreased. Closer to reality, this Account comprises a set of Ledgers that are added to when the balance changes, and the balance itself is not a number but the sum of those Ledgers.

My mental model is that there is an Account instantiation that represents the state of the transaction log (the ā€œreal accountā€) rather than being the transaction log. It is a temporary proxy, and such proxies come and go. From the perspective of banking system architecture the class is misnamed: it better should be named ā€œbusiness-level transaction."

Lund Soltoft

unread,
Nov 6, 2022, 9:08:46ā€ÆAM11/6/22
to object-co...@googlegroups.com


Den 6. nov. 2022 kl. 12.19 skrev James O Coplien <jcop...@gmail.com>:

ļ»æ


On 2 Nov 2022, at 14.34, Lund Soltoft <lunds...@gmail.com> wrote:

If I play a game of D&D with my friends, does that game exist and is it different from the game of D&D Iā€™ll play with my brother in law and his wife tomorrow?

This is qualitatively different from what Andreas is asking, because your example is a new game every time, whereas the account example is a continuous set of data across time. Forgetting all data is O.K. in your case but not in his.
A game of D&D goes on forever and each (trans)action of the players is added to the previous. Itā€™s the accumulated effect of all these (trans)actions that describes the current state. So I beg to differ šŸ˜Š. However that was not my point. My point was that the a) that we can talk about individual games because they do have an identity and that Id of each of these games are not based on the role players.Ā 

I'm considering an Account that is slightly more sophisticated than one with a number that can be increased/decreased. Closer to reality, this Account comprises a set of Ledgers that are added to when the balance changes, and the balance itself is not a number but the sum of those Ledgers.

My mental model is that there is an Account instantiation that represents the state of the transaction log (the ā€œreal accountā€) rather than being the transaction log. It is a temporary proxy, and such proxies come and go. From the perspective of banking system architecture the class is misnamed: it better should be named ā€œbusiness-level transaction."

--
You received this message because you are subscribed to the Google Groups "object-composition" group.
To unsubscribe from this group and stop receiving emails from it, send an email to object-composit...@googlegroups.com.

James O Coplien

unread,
Nov 6, 2022, 9:26:28ā€ÆAM11/6/22
to noreply-spamdigest via object-composition


On 6 Nov 2022, at 15.08, Lund Soltoft <lunds...@gmail.com> wrote:

A game of D&D goes on forever and each (trans)action of the players is added to the previous. Itā€™s the accumulated effect of all these (trans)actions that describes the current state. So I beg to differ šŸ˜Š. However that was not my point. My point was that the a) that we can talk about individual games because they do have an identity and that Id of each of these games are not based on the role players.Ā 

O.K., thanks for the clarification.

Nonetheless, and further ā€” if that is so, then there is only one game (locus of state), and the presence of intervening time does not change role/actor bindings of the game proper.

You may have individual sessions. If there are some per-session artefacts, each one is just a proxy for the game ā€” just like an ā€œAccount objectā€ is a proxy for the transaction logs and audit trails.The proxy must provide the illusion of preserving identity, but in the real game, there must be a level at which identity is really preserved.

Having a Tardis would cause your setup to violate identity. You avoid this only by eliminating proxies.

Lund Soltoft

unread,
Nov 6, 2022, 1:16:56ā€ÆPM11/6/22
to object-co...@googlegroups.com
M

Den 6. nov. 2022 kl. 15.26 skrev James O Coplien <jcop...@gmail.com>:

ļ»æ


On 6 Nov 2022, at 15.08, Lund Soltoft <lunds...@gmail.com> wrote:

A game of D&D goes on forever and each (trans)action of the players is added to the previous. Itā€™s the accumulated effect of all these (trans)actions that describes the current state. So I beg to differ šŸ˜Š. However that was not my point. My point was that the a) that we can talk about individual games because they do have an identity and that Id of each of these games are not based on the role players.Ā 

O.K., thanks for the clarification.

Nonetheless, and further ā€” if that is so, then there is only one game (locus of state), and the presence of intervening time does not change role/actor bindings of the game proper.
Agreed and if the same players participate in another game, that game has a different identity than the first one, ie the identity is not given by the identity of the players. The game proper is it self a ā€œthingā€Ā 

You may have individual sessions. If there are some per-session artefacts, each one is just a proxy for the game ā€” just like an ā€œAccount objectā€ is a proxy for the transaction logs and audit trails.The proxy must provide the illusion of preserving identity, but in the real game, there must be a level at which identity is really preserved.

Having a Tardis would cause your setup to violate identity. You avoid this only by eliminating proxies.

--
You received this message because you are subscribed to the Google Groups "object-composition" group.
To unsubscribe from this group and stop receiving emails from it, send an email to object-composit...@googlegroups.com.

James O Coplien

unread,
Nov 6, 2022, 1:48:32ā€ÆPM11/6/22
to object-co...@googlegroups.com
Aha, now get it. I had your meaning backwards.

Matthew Browne

unread,
Nov 9, 2022, 5:54:20ā€ÆAM11/9/22
to object-co...@googlegroups.com
In the Marvin example at least (https://fulloo.info/Examples/Marvin/MoneyTransfer/Listings/Account/), Account is a Context rather than a regular class. We could debate whether or not a Context makes sense in cases like that example, which is almost certainly simplified compared to a real Account object in a production banking system, where it seems likely that there would be more interaction requiring role-playing objects for Account functionality rather than just basic instance methods. But regardless of whether it's defined as a class or a context, I think Account is more than just the ledgers because it could potentially play a role in more than one context - it's not only the ledgers data, but also the methods to retrieve and update the ledgers that should come along with the Account wherever it needs to be used. In theory I suppose you could have something like `class Account extends List<Ledger>` where the Account itself is a List of ledgers, but that seems wrong because you'd then be exposing the List methods as public methods of Account.

This question also reminds me of earlier discussions about whether we really need classes anymore, and what exactly is the distinction between a class and a context. If I were creating a brand new language, my current thinking (inspired by Rune) is that I wouldn't include classes at all because Contexts can do everything classes can do except for inheritance, and the goals of inheritance can be achieved via other means. So I would broaden the definition of a Context to include what we would traditionally think of as classes - templates for creating objects that don't necessarily even contain any roles.


Matthew Browne

unread,
Nov 9, 2022, 6:05:21ā€ÆAM11/9/22
to object-co...@googlegroups.com
On a different note, I was just thinking about how overloaded the word "context" is when discussing programming. At this point I think it would be impractical to rename "context" in DCI and I think it might still be the best name even without that consideration, but it occurred to me that 'stage' could be an alternative name. So the 'stage' is where the interaction happens, and it fits nicely with 'roles' and 'stage props' played on that stage. Or maybe the context is more like a 'scene' in a play (and of course in a real play, all the scenes happen on the same stage), but I like 'stage' because it still works with the broadened definition of a context I described in my previous post.

James O Coplien

unread,
Nov 9, 2022, 8:05:59ā€ÆAM11/9/22
to noreply-spamdigest via object-composition


On 9 Nov 2022, at 11.54, Matthew Browne <mbro...@gmail.com> wrote:

This question also reminds me of earlier discussions about whether we really need classes anymore, and what exactly is the distinction between a class and a context. If I were creating a brand new language, my current thinking (inspired by Rune) is that I wouldn't include classes at all because Contexts can do everything classes can do except for inheritance, and the goals of inheritance can be achieved via other means. So I would broaden the definition of a Context to include what we would traditionally think of as classes - templates for creating objects that don't necessarily even contain any roles.

Like.

Lund Soltoft

unread,
Nov 9, 2022, 8:59:56ā€ÆAM11/9/22
to object-co...@googlegroups.com

> This question also reminds me of earlier discussions about whether we really need classes anymore, and what exactly is the distinction between a class and a context. If I were creating a brand new language, my current thinking (inspired by Rune) is that I wouldn't include classes at all because Contexts can do everything classes can do except for inheritance, and the goals of inheritance can be achieved via other means. So I would broaden the definition of a Context to include what we would traditionally think of as classes - templates for creating objects that don't necessarily even contain any roles.
This is very much how I see DCI. Which is also why I wrote the account as I did. In the real world model I think I counted 27 different types making up what the bank customer sees as an account (I used to be an architect on an internet banking solution which is where I saw the ISO standard for Modeling an account but I canā€™t remember the actual number of types but it was more than 20).
In my view of DCI there are data and context objects. Data objects are either a primitive type or a collection primitive types. Everything else is a context.
Reply all
Reply to author
Forward
0 new messages