{"action":"created","issue":{"url":"https://api.github.com/repos/saturnflyer/surrounded/issues/28","labels_url":"https://api.github.com/repos/saturnflyer/surrounded/issues/28/labels{/name}","comments_url":"https://api.github.com/repos/saturnflyer/surrounded/issues/28/comments","events_url":"https://api.github.com/repos/saturnflyer/surrounded/issues/28/events","html_url":"https://github.com/saturnflyer/surrounded/issues/28","id":123827286,"number":28,"title":"Surrounded vs Casting","user":{"login":"jonahx","id":699684,"avatar_url":"https://avatars.githubusercontent.com/u/699684?v=3","gravatar_id":"","url":"https://api.github.com/users/jonahx","html_url":"https://github.com/jonahx","followers_url":"https://api.github.com/users/jonahx/followers","following_url":"https://api.github.com/users/jonahx/following{/other_user}","gists_url":"https://api.github.com/users/jonahx/gists{/gist_id}","starred_url":"https://api.github.com/users/jonahx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jonahx/subscriptions","organizations_url":"https://api.github.com/users/jonahx/orgs","repos_url":"https://api.github.com/users/jonahx/repos","events_url":"https://api.github.com/users/jonahx/events{/privacy}","received_events_url":"https://api.github.com/users/jonahx/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-12-24T18:34:47Z","updated_at":"2015-12-29T21:01:31Z","closed_at":null,"body":"Hey Jim, one more quick question.  I was checking out Casting as well, and thinking about when you'd use that vs Surrounded.  Here's what I came up with.  Can you let me know if this rings true for you, or if you have anything to add:\r\n\r\n1. DCI style programming can be done with either Surrounded or Casting\r\n2. Casting is a \"smaller buyin\" approach, in that you don't have to touch your domain objects at all (vs Surrounded, where you have to \"include surrounded\" in them).  \r\n3. For this reason, Casting can be considered more of a library approach, vs Surrounded, which might be considered more of a framework approach.  That is, if you use Surrounded on a project, \"Surrounded\" stuff is going to be in both your domain objects and your use-case objects/modules.  With Casting, it's not *really* in either, other than a few calls to `cast_as`\r\n4. The flip side of point 3: With surrounded, you get more sugar and convenience methods that clearly map to the higher level concepts of DCI.\r\n\r\nIs this all fair?  Anything I'm missing?"},"comment":{"url":"https://api.github.com/repos/saturnflyer/surrounded/issues/comments/167876805","html_url":"https://github.com/saturnflyer/surrounded/issues/28#issuecomment-167876805","issue_url":"https://api.github.com/repos/saturnflyer/surrounded/issues/28","id":167876805,"user":{"login":"saturnflyer","id":4271,"avatar_url":"https://avatars.githubusercontent.com/u/4271?v=3","gravatar_id":"","url":"https://api.github.com/users/saturnflyer","html_url":"https://github.com/saturnflyer","followers_url":"https://api.github.com/users/saturnflyer/followers","following_url":"https://api.github.com/users/saturnflyer/following{/other_user}","gists_url":"https://api.github.com/users/saturnflyer/gists{/gist_id}","starred_url":"https://api.github.com/users/saturnflyer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/saturnflyer/subscriptions","organizations_url":"https://api.github.com/users/saturnflyer/orgs","repos_url":"https://api.github.com/users/saturnflyer/repos","events_url":"https://api.github.com/users/saturnflyer/events{/privacy}","received_events_url":"https://api.github.com/users/saturnflyer/received_events","type":"User","site_admin":false},"created_at":"2015-12-29T21:01:31Z","updated_at":"2015-12-29T21:01:31Z","body":"I use both of these libraries. I hope to make some videos about how they work and want the differences are.\r\n\r\n1) Your first point is true. Using Casting previously would require a bit of work to get things going in a way similar to Surrounded but I've pushed some changes that might interest you. More on that in a bit...\r\n\r\n2 & 3) I try as hard as possible to make a small buy-in and reasonably allow you to implement things differently if you like.\r\nSurrounded has many places to override the default behavior and provide your own ideas, but it also provides a lot of good options to try.\r\nWith Casting, you still need to `include Casting::Client` in order to use it. That only adds some methods like `cast` (aliased to `delegate` if that method doesn't already exist) which executes behavior on an object immediately when called.\r\nWhat Surrounded provides is the building blocks for a context object: that is to say, it's more like a framework for building objects with a specific runtime relationship to each other. Casting, on the other hand, provides tools for adding behavior to objects.\r\nSurrounded also adds behavior to objects, but the main goal is to create the contexts.\r\nEven with Casting, your objects still need to `include Casting::Client` and it will use `method_missing` on those objects to automatically use behavior **only** if you opt-in to that by using `delegate_missing_methods`.\r\nYou can use Casting without using `method_missing`.\r\nSurrounded, however, mostly relies on `method_missing` and is a must in your domain objects _only_ in certain styles. You can for example implement role behavior in Surrounded using `wrapper` or `interface` which are an objects that handle `method_missing` allowing you to keep it out of your domain objects.\r\n\r\n4) There's lots' of sugar in Surrounded for doing things in context objects. There's opt-in sugar in Casting for doing things in domain objects too. Using `method_missing` being one of them, but you can also opt-in to adding details about behaviors when getting a list of methods from an object. For example you can `include Casting::MethodConsolidator` in your domain object so that when you list all the known behavior for that object, it'll include those added by modules used by Casting: `object.methods #=> list of all methods defined in the object class AND those from the modules`\r\n\r\nYour questions made me finally sit down to hammer out some ideas for using Casting to build Contexts.\r\nThis **requires** the use of refinements, so it's not required by default. See https://github.com/saturnflyer/casting/blob/master/examples/delegation_dci.rb and https://github.com/saturnflyer/casting/blob/master/lib/casting/context.rb\r\nThat also uses method_missing, but it's added as a refinement and I'll probably hack it to make that optional.\r\n\r\nFeel free to ask anymore questions but bear with me if it takes a while for me to get back to you."}}