--
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 post to this group, send email to object-co...@googlegroups.com.
Visit this group at https://groups.google.com/group/object-composition.
For more options, visit https://groups.google.com/d/optout.
I am not sure Contexts are necessary objects/instances
Code in the Context perspective specifies runtime networks of interconnected objects
Code in the Context perspective specifies runtime networks of interconnected objects(Emphasis mine)
--
For example, many black boxes (objects) can play the role of Controller, but inside of this role, Controller is actually Context that has a script for Models and Views roles.
--
I don't understand. You said: "I am not sure Contexts are necessary objects/instances - this is just how it was chosen to implement contexts in specific languages" and I simply replied that by definition contexts are objects and a context can't be a role but it can be a roleplayer in a higher level context
To avoid confusion I would advice to using standard terminology. A role is played by a roleplayer. A context can be a roleplayer but not a role
On 26 Feb 2019, at 19.50, Oleh Novosad <oleh.n...@gmail.com> wrote:"can be a roleplayer in a higher level context"Yes, this is what I mean when I say that "context is role when looking from outside".
On 26 Feb 2019, at 20.03, Oleh Novosad <oleh.n...@gmail.com> wrote:Are you saying that I cannot assign Theatre role to other buildings?
Try restating this more precisely. “Assign” is not DCI-ese.
I think, my point is that Theatre is Context for humans/instances to play Dancer role.But at the same time Theatre is Role for buildings to play Theatre.
--
I would argue that the context isn’t the Theater building but that there’s a play-context that has several roles and that play-context plays a play role in the Theater context where “my house” (or another more suitable building) plays the role of venue
On 27 Feb 2019, at 00.06, Oleh Novosad <oleh.n...@gmail.com> wrote:Is there a way I can help you to understand what I am trying to say?
I would argue that the context isn’t the Theater building but that there’s a play-context that has several roles and that play-context plays a play role in the Theater context where “my house” (or another more suitable building) plays the role of venue
Is there a way I can help you to understand what I am trying to say?
context PlayContext {the point seems to be that a Context can play a role in another Context.
role CLAUDIUS {} // played by a human actor
role HAMLET {} // played by a human actor
...
}
context TheatreContext {
role VENUE {} // played by some building such as "my house"
role PERFORMANCE {} // played by an instance of PlayContext
...
}
I would argue that the context isn’t the Theater building but that there’s a play-context that has several roles and that play-context plays a play role in the Theater context where “my house” (or another more suitable building) plays the role of venue
############################################################################### This example shows pretty normal way of doint things
# Role definitionrole DANCER # dance method def dance() #... end end
context Theater # play show in theatre def play_show(dancer as DANCER) dancer.dance() end end
# Create human instance/objectbob = Human.new
# Create Theatre instance, check if bob can play DANCER role and pass it to play_show() script,
# execute play_show() scriptTheather.new.play_show(bob as DANCER)
############################################################################### This example shows how context could be not an object, # everything else is pretty standard
# Role definitionrole DANCER # dance method def dance() #... end end
context Theater # static/class method of Theather context def self.play_show(dancer as DANCER) dancer.dance() end end
# create human instancebob = Human.new
# here we call static/class method of TheatreTheather.play_show(bob as DANCER)
############################################################################### This example shows how previously Theatre context could be transformed into role
# Role definitionrole DANCER # dance method def dance() #... end end
role THEATHER # play show in theatre def play_show(dancer as DANCER) dancer.dance() end end
# create human instancebob = Human.new # create building instancebuilding = Building.new
(building as THEATHER).play_show(bob as DANCER)
############################################################################### Same as above but dancer being "inside" of building
# Role definitionrole DANCER # dance method def dance() #... end end
role THEATHER dancer as DANCER
# play show in theatre def play_show() dancer.dance() end end
# create human instancebob = Human.new # create building instancebuilding = Building.new(dancer: bob)
# budiling plays theatre role and execute show(building as THEATHER).play_show()
--
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 post to this group, send email to object-co...@googlegroups.com.
Visit this group at https://groups.google.com/group/object-composition.
For more options, visit https://groups.google.com/d/optout.
The essence of object orientation is
that objects collaborate to achieve a
goal.
Trygve Reenskaug mailto: try...@ifi.uio.no
Morgedalsvn.
5A http://folk.uio.no/trygver/
N-0378
Oslo http://fullOO.info
Norway Tel:
(+47) 22 49 57 27
the point seems to be that a Context can play a role in another Context.
the point seems to be that a Context can play a role in another Context.I think the opposite is also true, Role is Context for other Roles.
On 28 Feb 2019, at 19.24, Oleh Novosad <oleh.n...@gmail.com> wrote:I think the opposite is also true, Role is Context for other Roles.
On 28 Feb 2019, at 19.50, Oleh Novosad <oleh.n...@gmail.com> wrote:If Context can be Role it means Role is Context for what was inside of that Context. So it is just a logical conclusion that "Role is Context for other Roles".
I think you get too much into the language debate.In DCI:- Every object can play a Role in a Context- Context is an object so it can PLAY a Role in a Context (even within itself)Your theory does not make sense:You said:- a Context can play a role in another Context --> Yes- If Context can be Role it means Role is Context for what was inside of that Context --> does not make sense hereTo PLAY is not TO BE- So there is not such thing Context is Role and Role is Context.... --> this just has gone too far in the land of language mystery :)
Contexts can play Roles. Contexts are not Roles.
Maybe I can rephrase my point this way:Can I inject Context (not Context instance) into some object/instance in the same we do it with Roles? If not, why?
A role is part of a context and an object can be bound to play that role. When the binding happens the role methods become part of the roleplayer. If we differentiate between a context and a context instance, then a context is a compile type construct which can’t be injected into anything.
--
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 post to this group, send email to object-co...@googlegroups.com.
Visit this group at https://groups.google.com/group/object-composition.
For more options, visit https://groups.google.com/d/optout.
On 28 Feb 2019, at 21.39, Oleh Novosad <oleh.n...@gmail.com> wrote:Roles can be shared between contexts (I can be a Dancer not only in Theatre but also in Bar)
No.In the Context “Take Order” we find the Role Waiter, with its responsibilities related to what people want to eat.In the Context “Serve Food” we find the Role Waiter, with its responsibilities related to putting food on the table.
A Context is represented by an object. A role is NOT an object but merely a pointer to an object. So a Role can't be a Context.
Maybe I can rephrase my point this way:
Can I inject Context (not Context instance) into some object/instance in the same we do it with Roles? If not, why?
But if a person instance wants to do the same dance in Theatre context and in Bar contetx. I am sure can write executable Ruby code as I did before but it will not help you I think.
Relax. I love and respect Trygve and Cope and you. I definitely don't agree that Roles cannot be shared though between contexts. But that's it.
--
--
An object is a thing in itself.
A role exists in a Context of interacting objects that are represented by Roles.
In your example, a Dancer (an object, an instance of class Dancer) plays a Role named DANCER in a Context named Theater. The same Dancer plays another Role, also named DANCER, in a Context named Bar. The Roles may be named the same, but they are different because they interact with different objects in different environments (Contexts).
and I could write it in FORTRAN or as an essay in plain English. But neither supports the DCI programming paradigm so they can't help us here. It would help if you tried Cope's trygve language. It's well documented and its terms are well defined. Even a simple example will clear much of the fog.
Hi Oleh,
I think I understand your question better now, but I'm unclear on
your underlying goal. It seems like you are suggesting a
modification/extension to DCI to allow the use case logic in
Contexts to be reused in a different way, but is this just
academic or is it because you tried to use DCI as envisioned by
Trygve and Cope and had trouble with it? Have you used DCI in a
real app? Healthy skepticism of a new paradigm is a good thing,
but I suggest that you take a scientific approach and treat DCI as
an experiment. Remain open-minded and recognize that what you see
as shortcomings might not even be shortcomings at all as you
understand it better. This is not to say that DCI can't be
improved in any way or that DCI is the only valid paradigm—far
from it. But I think it's more than fair to expect people to
demonstrate a full understanding of DCI before any debate about it
can be productive. This group can help you come to that
understanding, but only if you take a step back and get out of
debate mode for a while.
Context (not a Context instance) is code (use-cases scripts). Can I bind this code to some object/instance in the same way we do it with Roles? If not, why?
I realize this probably seems counterintuitive (it was to me at first), but in practice I have never seen a situation where the exact same code for a role in one Context actually could be reused verbatim in another Context. Cope gave a good example of a role named "Waiter" in two different Contexts. Don't be misled by the fact that it has the same name—as far as DCI is concerned, the role in one Context is completely independent from a same-named role in any other Context. If you've encountered a real-life situation in a real-life DCI app where you felt the need to reuse the same role methods verbatim in multiple Contexts, I'd be interested to see it. I strongly suspect that by examining the example together with the group, you'd find that it could be reworked in a way consistent with DCI's mental model that was more elegant or equally elegant as the alternative you've been suggesting.
Finally, it's worth noting that keeping your code DRY isn't the foremost goal of DCI; DCI's primary emphasis is on keeping your code readable. Avoiding repetition is often complimentary with the goal of readable code of course, but not always. Sometimes a small amount of repetition (might only be a few lines) is more than worth the maintenance cost and mental overhead of a much more complicated but more DRY solution.
This is a little harsh, Trygve. Yes, Oleh was
prematurely criticizing DCI based on some mistaken assumptions.
But there is nothing in the group description (or some other
message sent to new members, as far as I know) that tells people
that this sort of premature debate is not welcome in this group.
Perhaps it should be obvious, but I don't think we should label
people as trolls based on what might have just been a wrong
expectation.
I got the impression that Oleh—who first posted in the group nearly a year ago, it looks like—is genuinely interested in DCI, albeit skeptical. Now that we've pointed out his mistaken assumptions, maybe he'll respond differently. Consider these quotes from Oleh:
Is there a way I can
help you to understand what I am trying to say?
...
How can I show something
in a language that doesn't support what I want to show.
These sound to me like a person who is struggling to communicate their concern and/or confusion, not someone who's just intending to waste everyone's time.
To Oleh: Regarding your question about showing
your idea in code, before trying to demonstrate your alternative
idea, I would take a realistic example and implement it using
the trygve language, and show it to the group for feedback. After
that, you could use any language that allows you to inject
methods into objects at runtime (e.g. Ruby or JS) to show an
alternative way of implementing the same example. Then we could
actually have a productive discussion.
On 3/2/19 8:47 AM, Oleh Novosad wrote:
Being not able to share roles between contexts is stupid in my opinion.
--
You received this message because you are subscribed to a topic in the Google Groups "object-composition" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/object-composition/iEIh_gf0e_4/unsubscribe.
To unsubscribe from this group and all its topics, send an email to object-composit...@googlegroups.com.
I'm sad that it came to this. I don't think it had to end this
way. I think Oleh and Trygve both misread the situation. But
obviously we can't tolerate disrespectful people and it's too late
now.
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.
The core misunderstanding have been about sharing roles between contexts. In my Family context we have a role called daughter. Would it make sense to share that context with your family? Of course not. Not even if we expected the same behaviour of the role players. Why wouldn’t it make sense because a role is more that the role behaviour it’s also a node in an interaction graph and the role of being my daughter has some expected behaviour AND a relation to me. The only thing that might ever be duplicated in another family context is the expected behaviour but NEVER the interaction graph
Well said, Rune. This might be falling on deaf ears at this
point, but for posterity, perhaps one other thing worth adding is
that in DCI there are already ways to reuse behavior shared
between roles, including helper functions and shared nested
contexts. So in effect (loosely speaking), parts of roles
can be shared, but sharing the whole role wouldn't make
sense and is incompatible with the contextual role-based model
that makes DCI so effective.
- You can't inject a class into anything whatever inject means.
- inject is not a DCI word
In case it wasn't clear, "injection" in this case is short for "method injection", meaning to inject additional methods into an existing object at run-time.
On Wed, Mar 6, 2019, 10:35 AM James O Coplien <jcop...@gmail.com> wrote:
Yup. Injection is a technique. DCI semantics are at a higher level.
Sendt fra min iPhone
> Den 6. mar. 2019 kl. 16.05 skrev Rune Funch Søltoft <funchs...@gmail.com>:
>
>
>> Den 6. mar. 2019 kl. 15.45 skrev Daniel P <daniel...@gmail.com>:
>>
>> In what sense then is "inject" not a DCI word? Are you suggesting that the word "inject" does not belong in a formal treatment of DCI?
> When the book was written “injecting” was the way objects was enriched. This method turned out to be an implementation detail and not an intricate part of the DCI mental model.
> At the time the book was written at least Trygve saw injection as the only possible solution. I to some extend created Marvin to show that injection wasn’t required (trygve, the language, has later shown some issues that arose from some of my design decisions, specifically when inspecting the runtime).
> Another word has been use for quite some time. Bind. Binding of objects to a role has specific meaning in DCI.
>
> --
> 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-composition+unsub...@googlegroups.com.
> To post to this group, send email to object-co...@googlegroups.com.
> Visit this group at https://groups.google.com/group/object-composition.
> For more options, visit https://groups.google.com/d/optout.
--
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-composition+unsub...@googlegroups.com.
Yup. Injection is a technique. DCI semantics are at a higher level.
Sendt fra min iPhone
> Den 6. mar. 2019 kl. 16.05 skrev Rune Funch Søltoft <funchs...@gmail.com>:
>
>
>> Den 6. mar. 2019 kl. 15.45 skrev Daniel P <daniel...@gmail.com>:
>>
>> In what sense then is "inject" not a DCI word? Are you suggesting that the word "inject" does not belong in a formal treatment of DCI?
> When the book was written “injecting” was the way objects was enriched. This method turned out to be an implementation detail and not an intricate part of the DCI mental model.
> At the time the book was written at least Trygve saw injection as the only possible solution. I to some extend created Marvin to show that injection wasn’t required (trygve, the language, has later shown some issues that arose from some of my design decisions, specifically when inspecting the runtime).
> Another word has been use for quite some time. Bind. Binding of objects to a role has specific meaning in DCI.
>
> --
> 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-composition+unsub...@googlegroups.com.
https://stackoverflow.com/questions/9205083/traits-vs-interfaces:My mental model was that Trait methods were injected into the objects. (I very rarely worry about classes). I didn't like that a class had to know the Traits that enabled its instances to play Roles in Contexts: I wanted a stronger separation of concerns between Data and Context/Roles. My implementation was in Smalltalk and with Cope's help, a new mechanism using introspection gave me "injectionless" DCI. I have continued along this path and the "injection" went out of my vocabulary together with "Traits" many years ago.
Traits is a mechanism for code reuse in single inheritance languages such as PHP. A Trait is intended to reduce some limitations of single inheritance by enabling a developer to reuse sets of methods freely in several independent classes living in different class hierarchies.
Traits — on which Trygve’s implementation is based — are a mechanism for class composition. In the simple understanding of the word “inject” one can view traits as a way to inject two classes into each other.
The pretense in DCI is that the method associations happen at the object level, but behind the scenes there is always some kind of association of class-like things in all the implementations I know of. There are several mental models of DCI implementation, They are all just mental crutches, since at the level of the real flip-flops of memory nothing is being injected into anything.
We make convenient models that adjacent words of the address space are physically adjacent on the same chip in memory (which, because of memory fetch efficiency designs, may not be true) and at the next higher level think of objects and classes having nesting properties (which at the level of the bits is geometrically preposterous). So we create geometries that fulfill our fantasies. Rosen (the symmetry and symmetry-breaking guy) says that these geometries are just as “real” as the physical ones: they obey all the same laws of group function closure, composition, and inverses. So whether there is “injection” or not is largely a matter of a (rather arbitrary) choice of a mental model by which to reason about the geometry of objects in the machine. All that is in the machine are data: objects are information and, as such, live only in the mind.
Finally, DCI is an application of an additional mental model on top of the virtual machine.
One of the goals of the trygve project was to formalize this mental model in terms of a formally defined virtual machine. It exists. I think it has been only tacit in most other DCI implementations. So I think arguing about injection doesn’t lend much insight into the semantics of DCI. The main DCI semantics are behavioural and are better-suited to retract theory and describing compositions of behaviours rather than the geometry of physical metaphors. In the same sense that Ungar et al. showed that delegation and inheritance are logically equivalent, I would muse that one could do a formal analysis of DCI that shows that injection and other mechanisms are equivalent as regards most important properties of a DCI implementation.
Trygve seems to disagree since he just mentioned Baby as the first implementation of DCI, whereas the first implementation that was actually able to do this class composition properly, to implement the Context / Role / Class triple, was in C++.
The operational difference between the Baby implementation and the C++ traits implementation is largely in the compile-time overhead of code generation, which has never really arisen as a central salient DCI property.
All the other differences are artifices of the engineering mental model one applies. For example, if one object of class C plays role R in the C++ implementation, then all objects of class C can play role R. It doesn’t mean that one must use the role methods of those objects. In C++ a wayward invocation of such a method would succeed, which is inappropriate. In Smalltalk it is much better because the program crashes with a “method not understood” message.
The trygve implementation perfectly fixes both of these: it has moved on to create a practical, useful virtual machine based on a much more robust mental model than anything where we need to argue about whither injection.
On 7 Mar 2019, at 12.20, Trygve Reenskaug <try...@ifi.uio.no> wrote:I have the impression that only instances of classes defined within the scope of the trygve program can play roles in trygve. Don't you have to create a wrapper around a web service to make it play a role?
On 7 Mar 2019, at 12.20, Trygve Reenskaug <try...@ifi.uio.no> wrote:There is now work in progress to create a global standard for uniquely identifying every object in the world regardless of what it represents and how it is reified (particularly IoT things)
https://stackoverflow.com/questions/9205083/traits-vs-interfaces:
Traits is a mechanism for code reuse in single inheritance languages such as PHP. A Trait is intended to reduce some limitations of single inheritance by enabling a developer to reuse sets of methods freely in several independent classes living in different class hierarchies.
This is a bit off-topic, but since this quote mentions PHP, I
just wanted to point out that "traits" are implemented differently
in different languages (and some languages don't really have them
at all...they can usually be emulated somehow, but for
implementations that do source code transformation or for a
full-fledged DCI VM like trygve, traits are not needed at
all).
DCI is of course object-oriented rather than class-oriented, so
the trait implementations that lend themselves best to it are
those that let you add traits to specific objects. Scala
allows this via the 'with' keyword—example.
Note: that example is doing it at instantiation time, whereas in
DCI you should ideally be able to dynamically add roles to
existing objects when a particular use case (Context) begins. Ruby
and JavaScript, while lacking some of the dedicated traits
features that Scala has, both have the ability to inject methods
into an existing object, which comes in very handy for
implementing DCI...although as Rune mentioned, the method
injection technique still has issues, particularly when it comes
to removing the role methods after a use case ends. In
JavaScript you can use symbols
instead of string keys to avoid the need to worry about removing
role methods at all (example),
thanks to the fact that symbols are guaranteed to be unique and
not conflict with existing string keys (but admittedly the
dichotomy this creates between role methods and regular methods is
unfortunate).
Anyway, getting back to PHP, I thought it was worth mentioning that PHP does not have the same kind of flexibility when it comes to traits as any of the above languages. In PHP, you can add traits to classes at compile-time and that's it; you can't use them to directly add roles to individual objects. My DCI implementation for PHP actually does make use of traits, but not in the way you might expect. (My implementation only uses the traits as a convenient place for the programmer to write his/her role methods; at run-time it actually creates a new class that uses the trait to essentially copy over all the role methods so they can actually be called.)
--
On 7 Mar 2019, at 14.47, Trygve Reenskaug <try...@ifi.uio.no> wrote:I thought you didn't like wrappers because they can lead to identity problems.
--
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 post to this group, send email to object-co...@googlegroups.com.
Visit this group at https://groups.google.com/group/object-composition.
For more options, visit https://groups.google.com/d/optout.
The essence of object orientation is
that objects collaborate to achieve a
goal.
Trygve Reenskaug mailto: try...@ifi.uio.no
Morgedalsvn.
5A http://folk.uio.no/trygver/
N-0378
Oslo http://fullOO.info
Norway Tel:
(+47) 22 49 57 27