Sunday, February 3, 2008

Rails "components": I do not think that word means what you think it means.

Right now I have 2 gigs. One is a java gig where I am working on an application I helped develop about two years ago using Tapestry. The other is a Rails gig. This has given me a good opportunity to compare and contrast the two. So far my experience is that I love the Ruby language and don't want to go back to doing Java except when/if I need to to pay the bills. But Rails I'm not as sold on. Mind you I'm not here to bash on Rails, there are some great things there and other people have done a fine job of praising them. But there are some things I definitely miss from Tapestry, and the most significant one is components.

Now when I say components I don't mean that abomination they stuck in Rails and then deprecated. I mean "real" components in the style of WebObjects, Tapestry, and other frameworks in that lineage. To qualify as "real" components in my mind means 3 things:

1. Reusable view and controller logic.
This is the easiest and this is I think what the deprecated Rails components thing was attempting to address. I've seen several other attempts to do this in Rails with varying degrees of success. I think the Presenter pattern being bandied about is essentially another attempt to have this same aspect of "componenty-ness".

2. Composability.
Components should be able to be composed out of other components. I haven's seen something in Rails that did this well yet. It could be out there, but if it is I haven't seen it. And this is also where it gets a little controversial. From what I've seen, DHH and rails core seems to believe that "high level" component reuse is either not possible or worthwhile. Having seen it absolutely work and work well in Tapestry I have to respectfully disagree. The Tapestry Palette and Table components are both "high-level" and reusable on multiple projects to great affect. However even the discussion around component reuse seemed to me to be framed incorrectly, as it seemed focused on components being reused between applications. This is certainly possible, but I find much greater levels of component reuse within an application.

3. Binding.
This to me seems to be the most neglected feature of components, but in my mind is perhaps the most important. This is simply the ability to say something like "the value property of this text field is bound to @person.name". This should result in me being able to access @person with the name already set. I shouldn't have to touch the params hash at all. This would get rid of what I see as an imporant non-dry part of Rails. For example, why should I have to say in my view:

text_field "person", "name"

And then in my controller:

@person = Person.new(params[:person])

With binding I wouldn't have to.

The other place binding comes into play in component frameworks is events. Not only properties support binding, but events do as well. For example, a Button component could have a block bound to the "onlick" property. The framework then manages and abstracts away all the details of HTTP, etc.

I guess that's really what I miss: with a good component framework (and not all of them are) I feel like I am working at a higher level of abstraction. When building reasonably sophisticated web applications, I really miss that. With simple web sites, I don't so much.

So where am I going with all this? Well, I've been thinking about these ideas a lot since I started doing Rails and talking about them with my pairmate. Recently the ruby-component-web-frameworks Google group has been getting active again so I thought I'd blog about my ideas. I've started doing a little code experiment to see how it might look to implement some of these ideas as a Rails plugin. It seems not too difficult so far; it never ceases to amaze me how much I can say in so little Ruby code. When we have an SVN repo setup I'll share what I have but it's just an architecture spike right now.

14 comments:

JFinger said...

MysteryCoder, I completely agree with you, having come from both the C++ MFC/ATL COM world and Java.
Looking forward to what you come up with, being a new Believer in Ruby and Rails myself.

Matt Raible said...

I came across Cells today - is that what you're looking for?

MysteryCoder said...

Hey Matt, thanks for dropping by. Kinda, I think cells just does #1 from my list though. I really, really want binding too at a minimum. From what I've seen and heard cells doesn't do this (yet?).

Unknown said...

MysteryCoder, binding would be too high-level for cells, maybe you should look at Apotomo. it's a widget framework for rails where you could also write widgets which bind there input value, for example.

i totally agree with you on the components issue in Rails - it's also not only about reusability but also about clean encapsulation. the rails core guys seem to forget that.

Anonymous said...

If on the other hand, you need a detailed manual, the instructions are there for you to access.
...........................................................

Unknown said...

Check out Seaside (www.seaside.st)

Unknown said...

Check out Seaside (www.seaside.st)

Anonymous said...

. . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . good!

good!

Anonymous said...

池袋 風俗
渋谷 風俗
新宿 風俗
コンドーム 通販
アダルトDVD
av 写真
大人のおもちゃ
おとなのおもちゃ
大人のオモチャ
アンドロペニス
オナホール
コンドーム
ローション
SM 通販
男性セクシー下着
メンズ下着
メンズTバック
大規模修繕
決済代行
SEO
SEO
Grid geat grop
カード決済
ブライダルエステ
FX 初心者
クレジットカード 比較
仔犬
子ウサギ
仔ウサギ
アダルトショップ
アダルトグッツ
ゴールドカード審査
調査料金 探偵
行動調査 探偵

Anonymous said...

夫の浮気調査 探偵
身元調査 探偵
所在調査 探偵
浮気調査
ストーカー調査
素行調査
盗聴調査
身元調査
不倫調査
不倫調査
尾行調査
企業調査
身元調査
身辺調査
夫の浮気 相談
浮気 相談
身上調査 相談
所在調査 相談
不倫調査 相談
盗聴調査 相談
結婚詐欺 相談
オナホール
ビジネス英語
外資 英語

wcupcakes said...

i never did understand rails,sopracciglia perfette because acconciature capelli lunghi was to go here acconciature da sposa

Unknown said...

I suppose that Buy rs goldis certainly truly some tips i pass up: with a aspect platform (and not most of them are) I believe just like We are working at the advanced associated with abstraction. While constructing realistically superior world wide web software, I seriously overlook that.Cheapest Diablo 3 gold Having uncomplicated websites, I can't a great deal.

Unknown said...

Right now I have 2 gigs. One is a java gig where I am working on an application I helped develop about two years ago using Tapestry. The other is a Rails gig. This has given me a good opportunity to compare and contrast the two. So far my experience is that I love the Ruby language and don't want to go back to doing Java except when/if I need to to pay the bills. But Rails I'm not as sold on. Mind you I'm not here to bash on Rails, there are some great things there and other people have done a fine job of praising them. But there are some things I definitely miss from Tapestry, and the most significant one is components.
swtor gold
buy swtor gold
cheap swtor gold
tor credits
buy tor credits
cheap tor credits

Unknown said...

MysteryCoder, I completely agree with you, having come from both the C++ MFC/ATL COM world and Java.
Looking forward to what you come up with, being a new Believer in Ruby and Rails myself.guild wars 2 gold
buy guild wars 2 gold
cheap guild wars 2 gold
cheapest guild wars 2 gold
guild wars 2 gold for sale