ActionPack? Not so fast

August 29th, 2006

Rob Conery has released what he likes to call ‘ActionPack’ and the crowd has gone wild. Unfortunately, for those that knows a little bit about RoR, his ActionPack has little or nothing to do with what RoR provides. Kevin hit the nail on his post about it. I watched the web cast eager to see something exciting. Well it was a very good presentation and Rob is very competent on whatever he put his mind into. But his ActionPack project is about data access, not a paradigm shift to MVC which the original RoR’s ActionPack stands for.

Quoting

that kind of programming doesn’t allow you to use an object-oriented approach

Which refers to the following code

GridView1.DataSource = Product.FetchAll(); // Which returns a IDataReader

The approach is indeed ten times better than dealing with datasets and related stuff. But returning a IDataReader doesn’t quite support the OO argument. Shouldnt the Product.FetchAll return a ProductCollection instead? Maybe I’m being purist about OO, but if you want to make that claim, you better provide a more OO driven design.

So what I recommend here, and this is just our convention, is if you find yourself doing this on a Page, better to go to the App_Code directory, make a controller something like a ProductController that returns collections and in that controller is where you have this code

Refering to

IDataReader rdr = Product.FetchAll();
ProductCollection coll = new ProductCollection();
coll.Load(rdr);
rdr.Close();

A controller is not a data access layer, at least not in my conception (I’ve been wrong before, though). IMHO a controller is in charge of the application flow. Since the Smalltalk days, where the MVC was born, the controller role was to receive an input, work on it — not rare delegating to a more specific layer — and making data available to the views (intentional plural form). MVC can be applied to a text box and to a complex business page without losing its strictness to the concept.

For example (I won’t even use MonoRail here as if I do people will accuse me of being too biased) in RoR you can have

class ProductController < ApplicationController

  def hitme
    render_text 'Nice huh'
  end

end

And invoke it from your browser using the url “/product/hitme”. Is this a data access class in any way? You can call it names, torture it, give eletric shocks but it won’t turn into a data access class.

Rob missed the point about ActionPack, the RoR idea and its concepts but nevertheless any attempt to break the standard MS way to create application deserves respect and enthusiasm. Especially those engineered to make developers life easier. Hence keep up the good work!

Categories: General | Top Of Page | |

8 Responses to “ActionPack? Not so fast”

Rob Conery Says:

You know I really blew it when I named this project :). I am a Rails enthusiast and want to bring that simplicity over badly. I started with the DAL and am bleeding outward. In fact I would love to convince you to ditch nHib and let’s gang up! Anyway - I do want to respond to some of your points - I think I was misunderstood…

The Fetchers might indeed want to return collections, however it’s not always needed (like when binding to a control). In my point of view, and what my follow-on point was, is that whatever you want to do should be part of a larger Controller. No, controllers are not part of a DAL, but that’s not what I was suggesting. What I merely was pointing out was that direct object CRUD shouldn’t be in your pages - it should be in a business method inside your controller. I think you and I agree on this really, and my fumbling at words made it come out backwards :).

I didn’t really miss the point on ActionPack, despite the name. This is just step one of great aspirations and right now my foot is firmly planted on my rear for the confusion…

Anyway - I really really really dig your project and would really love to make it work with our version of “ActiveRecord”.

Thanks for taking the time to put some details down here…

Colin Ramsay Says:

Hi Hammett - here is another post on this Action Pack, this time advocating including it with Atlas.

http://weblogs.asp.net/jgalloway/archive/2006/08/30/SubSonic-_2800_formerly-ASP.NET-ActionPack_2900_-_2D00_-Microsoft-should-ship-this-with-Atlas.aspx

Horrible!

Community Blogs Says:

Interesting interview question

Hamilton Verissimo posts details about an interesting interview questions Interesting snippet Via Zen

hammett Says:

Hey Colin, yeah that doesnt look good either. These kind of post makes me consider that whoever is involved in the MS plataform has a very flawed brain, myself included… damn, I need to code some more on java.

Jeremy Says:

>Shouldnt the Product.FetchAll return a ProductCollection instead?

From a true OOP perspective the product itself should only be able to load one product at a time. I would think you would rather want to do

ProductCollection.FetchAll - which returns a collection of products.

A single product itself should not know or care how to load/return multiple products - that’s the whole point of a collection.

hammett Says:

Jeremy, I don’t think there’s the right and wrong way here. I can say that a product should not care about loading or persisting it too. I can say that a collection should not care about loading elements itself. Differents schools of thought, different conceptions, beliefs and consequentially design.

Rob Conery Ramblings Says:

Why Is Ruby Fun? Ask My Level 50 Illusion/Radiation Controller.

ASP.NET Chinese Blogs Says:

跟踪ASP.NET ActionPack/SubSonic

ASP.NET ActionPack被作者重新命名为SubSonic - The Zero Code DAL(亚音,零编码数据访问层)。 因为Castle/Rails界的反应(1,2),作者也意识到原来的名字有点误导。新名字来自2个作者最喜爱的乐队,Sublime…

Leave a Reply