Den 18. okt. 2017 kl. 13.45 skrev Ritchie Paul Buitre <rit...@richorelse.com>:
- Instead of Object#extend it uses wrappers.
--
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-composition@googlegroups.com.
Visit this group at https://groups.google.com/group/object-composition.
For more options, visit https://groups.google.com/d/optout.
Note that we have a wiki entry about this topic:
http://fulloo.info/doku.php?id=why_isn_t_it_dci_if_you_use_a_wrapper_object_to_represent_the_role
On Wed, Oct 18, 2017 at 8:44 AM, Ritchie Paul Buitre <rit...@richorelse.com> wrote:
Jim,Here's my attempt at Dijkstra algorithm.I've also adapted the test.In my implementation I combined Module with Delegator using Ruby Refinements, forwarding messages to the delegated object.While in the context roles with the new behaviors can be accessed using the methods named after the role. The original value without the behavior can still accessed using instance variables named after the role.With a role named 'user' the instance variable is '@user'.One advantage I've found using wrappers over Object#extend is that I don't have to worry about name collisions. I could define different behaviors with the same method for the same object on different roles.I've written more examples here: https://github.com/RichOrElse/wrapper-based/tree/master/examples
--
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+unsubscribe@googlegroups.com.
Den 19. okt. 2017 kl. 12.24 skrev Ritchie Paul Buitre <rit...@richorelse.com>:It works well enough for all use cases including the Dijkstra algorithm.
Den 19. okt. 2017 kl. 12.24 skrev Ritchie Paul Buitre <rit...@richorelse.com>:
But if you want I'll rewrite it to fit the roles given here:
Den 22. okt. 2017 kl. 06.47 skrev Ritchie Paul Buitre <rit...@richorelse.com>:That's what led me to write WrapperBased even though it is not pure DCI but I am confident about it's adoption among the Ruby community and revive interest.
Hi Ritchie,
Object.extends is probably still be the best option for production
usage in native Ruby. However, there's one other possibility you
could look into: you could try wrapping the role-playing object
rather than the role. In that case the entity of the original
object is preserved. This might work pretty well you can use
Object.extends to inject the "RolePlayer" behavior (I haven't
looked into it myself so I don't know how well it would work in
practice).
I used this approach successfully in PHP; here's a simplified
code example:
https://gist.github.com/mbrowne/37d4c8e7dbda031ba3b86fcfde04f5d8
Full library here:
https://github.com/mbrowne/dci-php
But unless you are having a lot of issues with naming conflicts due to the inability to unextend in Ruby, like I said you might be better off with Object.extends.
I have a few other comments which I'll share in a subsequent post
(probably will have time for that later today).
Cheers,
Matt
--
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.
Thanks Matt,I like your suggestion, wrapping role player object is less messy than wrapping the wrapper. I already have an implementation in mind with a list of improvements inspired by this challenge. I'll be back with my solution.