Skip to content

Instantly share code, notes, and snippets.

@lholden
Created April 12, 2012 20:41
Show Gist options
  • Save lholden/2370848 to your computer and use it in GitHub Desktop.
Save lholden/2370848 to your computer and use it in GitHub Desktop.
[2:00 PM] <@lholden> a library for DCI with Ruby : https://github.com/cjbottaro/schizo
[2:01 PM] <@lholden> I like that way better then the #extend pattern
[2:02 PM] <Skif> I'm liking Data Mapper (not DataMapper) as the inverse of DCI: http://solnic.eu/2012/01/10/ruby-datamapper-status.html
[2:05 PM] <Skif> Note that the linked article does refer to DataMapper, but it's the as yet unrelease 2.x branch
[2:05 PM] <@cschneid> lholden: is there a speed comparison?
[2:05 PM] <@cschneid> I do like it
[2:06 PM] <@cschneid> but dynamically creating fascades everywhere could be expensive
[2:06 PM] <@cschneid> or not. No idea.
[2:06 PM] <@lholden> Eh... most of the time the expense of this sort of stuff wouldn't really be an issue for us. Though, I guarantee it has an overhead :)
[2:06 PM] <@cschneid> sure
[2:06 PM] <@cschneid> we do lots of other slow stuff all on our own
[2:07 PM] <@lholden> Well, I mean to say... the delegate usage will likely not be a bottleneck hahaha
[2:09 PM] <@cschneid> device.as(Thermostat) do... end
[2:09 PM] <@cschneid> lholden: ?
[2:09 PM] <Skif> you can use Data Mapper with DCI, to be sure
[2:10 PM] <@cschneid> Skif: yeah, they're sorta orthogonal.
[2:10 PM] <Skif> but it feels like DCI is less needed with a Data Mapper pattern
[2:10 PM] <@lholden> Skif: *shrug* I kinda like DCI over Data Mapper personally
[2:12 PM] <Skif> DCI to me feels like hacking around ActiveRecord
[2:12 PM] <@lholden> cschneid Thermostat really is more of a type of Device... device.as(Commissionable) {} maybe
[2:12 PM] <@cschneid> ohh right.
[2:12 PM] <Skif> Data Mapper feels more like a cohesive approach
[2:12 PM] <@cschneid> but how would you then build that
[2:12 PM] <@cschneid> hmm
[2:13 PM] <@cschneid> Commissionable role would know how to commission a device, and inject a #commission method?
[2:13 PM] <@cschneid> presumably just by switching on device_type and injecting the correct sub-role
[2:14 PM] <@lholden> Skif: Data Mapper and DCI solve different problems IMHO. DCI is about localizing business concerns where Data Mapper is separating persistence from business.
[2:14 PM] <Skif> lholden: to be sure, as I mentioned they are not dependent
[2:14 PM] <Skif> but it feels like with AR you *need* DCI
[2:14 PM] <@lholden> Skif: Not that I am saying DM would be wrong either
[2:15 PM] <Skif> whereas with Data Mapper, you can use it if you want, but it's possible to build less heavyweight models and still keep your logic in one place
[2:15 PM] <Skif> basically, I think Data Mapper provides a more quickly-recognizable win, whereas DCI requires more work to get there.
[2:15 PM] <Skif> less work with somethign like Schizo, tho
[2:16 PM] <Skif> and Data Mapper is easier to migrate piecemeal
[2:16 PM] <@lholden> Though either way you look at it, splitting up our models would be a total win. I've never been a big fan of fat models... they make proof really difficult.
[2:17 PM] <@lholden> At the very least, I would love to see us localize a lot more logic out into modules that get mixed into our models.
[2:18 PM] <@lholden> And is even easier to handle piecemeal :P
[2:18 PM] <Skif> sure
[2:18 PM] <@lholden> mixed in ala definition time vs 'run time'
[2:18 PM] <Skif> sure
[2:19 PM] <Skif> I like the DCI way of that breakout, though, if we have to go that way, because you can pretty much bet that the previous line where you did @obj.extend(Role) is where the next line's code is defined
[2:19 PM] * lholden snickers
[2:19 PM] <@lholden> Ruby community is such full of fads :)
[2:19 PM] * Skif almond joys
[2:19 PM] <Skif> mmm, candy bars
[2:23 PM] <Skif> Comverge is now adopting FDD
[2:23 PM] <Skif> Fad-Driven Design
[2:23 PM] <@lholden> hahaha
[2:23 PM] <@lholden> Now, do you have proper fad coverage?
[2:23 PM] <Skif> That's why I want to go DM 2.x, because it's not the fad of the day ;-)
[2:24 PM] <Skif> honestly, I just like it, the fact that it's not a fad is just a plus
[2:24 PM] <@lholden> By that logic, we should use Sequel. Fantastic ORM... will never be a fad because for some reason nobody thinks of it.
[2:24 PM] <Skif> I think of it, I just don't like it as much
[2:25 PM] <@lholden> Sounds like an abusive relationship
[2:27 PM] <@cschneid> how about rails 3.2 first? :)
[2:28 PM] <@lholden> Not related, but interesting: http://sequel.heroku.com/2011/07/16/dangerous-reflection/
[2:28 PM] <@lholden> cschneid: I vote Ruby 1.9.3 first :)
[2:29 PM] <@lholden> Preferably before Rails stops supporting 1.8.7 :)
[2:29 PM] <@cschneid> by then ruby 2.0 will be out
[2:29 PM] <@cschneid> lets just migrate to that
[2:30 PM] <@lholden> migrating to 2.0 will from 1.9.3 should be pretty easy
[2:30 PM] <Skif> can you ruby-debug inside 1.9.3 yet?
[2:30 PM] <@lholden> isn't 1.9.x supposed to be their major code breakage
[2:30 PM] <Skif> without ugly hackery?
[2:30 PM] <@lholden> Skif: Technically yes with a patch
[2:31 PM] <@lholden> er... that would be sans hackery
[2:31 PM] <@lholden> er
[2:31 PM] <Skif> heh
[2:31 PM] <@lholden> er
[2:31 PM] <@lholden> not sans... double negative... that would be with hackery
[2:31 PM] <Skif> avec hackerie
[2:31 PM] <Skif> hey, I passed Grade 9 French
[2:32 PM] <@cschneid> yes, they just released a better debugger for 1.9.3
[2:32 PM] <@lholden> Skif: It's okay, I passed 9th grade
[2:32 PM] <@cschneid> diff gem name, but it works, and it's the same great debugger interface
[2:32 PM] <Skif> awesome, cschneid
[2:32 PM] <@cschneid> ruby5 told me
[2:32 PM] * Skif is behind on ruby5
[2:33 PM] <@ruby5> cschneid: I hate you, stop pretending I talk to you
[2:33 PM] <@cschneid> skif, why are you behind ruby5
[2:34 PM] <Skif> been riding my motorcycle and can't listen while riding
[2:34 PM] <Skif> s/can't/refuse to/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment