Cherry-Picking RoR Features for ASP.net
As I continue my exploration of dynamically typed languages and web frameworks, I decided to see how much of the Rails features I could get into ASP.net but still keep the performance and flexibility that I do appreciate about ASP.net. I thought about the things I really do like about RoR, and here were the features that I had really found myself appreciating the most:
1. Database migrations – Using this aspect of RoR was like having someone slap me across the face and saying ‘what have you been doing all this time –here is a better way.’ Definitely have to go this route.
2. ActiveRecord – I really like the model of using a very accessible way to do CRUD operations. I have never been a big fan of stored procedures, except for the most secure operations or ultra-complex database operations (for me, that is usually less than 5 queries in an entire application).
3. Integration of Testing – The generation process that also creates some of the tests you need is awesome. Big timesaver and really useful for keeping me honest.
4. Environment Configuration – I love the differentiation of dev, test, and prod. Tough one for ASP.net, but this is really a critical feature as I go forward.
5. Organization – This is almost a given at this point, but the clear organization of models, controllers, and views is definitely how I want to work.
6. Test fixtures – RoR does a great job of letting you define the data to do your testing on. I’ve felt the pain before of not doing this right, and RoR gave me some good ideas on how to do this better.
7. Multiple rendering from an action – Not sure how I can do this in ASP.net, but I do appreciate the output of js, html, xml, etc from a single controller. I would really rather have each of these be separate actions, but I do appreciate the application of the DRY approach here.
8. Capistrano – I found Capistrano to be much easier to work with than NAnt and MSBuild.
So, that’s my wish-list for ASP.net. Now, what have I found so far (if you read this and have other suggestions, please throw them out):
1. I was surprised to discover how many migration-based tools were available for ASP.net. I ended up settling on Migrator.net, since it let me store the migrations as classes and since it let me call an OnComplete event to do custom aspects of my migrations. For example, I wanted RoR-like created_at and updated_at data, and I wanted the Userstamps plugin functionality that I use a lot of in RoR. Lastly, I wanted the timestamp feature of SQL server, so I could write custom code to generate this SQL specific data type (I realize it isn’t really SQL specific, but Migrator.net doesn’t currently support this, and the app I am building will be on MS SQL, so I’m ok with closing this door. Plus, it’s 3 lines of code that I re-use over and over as a static method).
2. LINQ to SQL is growing on me with respect to matching the ActiveRecord pattern. I started using PLINQO, and I really like the data access layer it generates. While it doesn’t do the dynamic additions like RoR (find_by_whatever_the_field_name_is), it does give me the most common one of FindById. Very nice. It’s not generating the tests yet, so it’s not perfect, but it’s getting me pretty close.
3. The MS MVC extension helps for testing, but I still wish that PLINQO would generate the tests. But, the MS Testing tools are not bad for generating the tests from a class. In some ways, they are better than Rails, since it inspects my class and generates a test for each method; in Rails, I had to do this by hand once I started adding my own methods.
4. I haven’t found an answer yet for the environment configuration. I’m not convinced it’s possible, but if anyone has a suggestion, please, please, please throw it out there.
5. MS MVC does most of the organization for me. I do like that I can create separate projects for some re-usable code, too, so this is a check-plus.
6. I’m still mulling this over. I am using Rhino mocks, and I have some tests that generate data in the DB, but I don’t feel like I’m where I want to be on this one yet. I’m thinking I will create some XML files for data to load in the test database, but this goes back to my problem in 4. I want a separate connection for my tests. I’ve got a workaround, but it feels like a cludge, since I am storing my connection string as a const in my test project.
7. I haven’t really had to deal with this yet, but I think I am going to end up with separate projects for my views and my services while still using a consistent set of business logic. Will probably write a separate post on how I handle this later.
8. This is on my to-do list. I really would like to find a good GUI for developing my NAnt, CruiseControl, and other scripts. Suggestions welcome.
I’ll probably keep adding to this topic over time. My intro to RoR really taught me to be more open-minded about how I do things, and there are so many things that could be carried over into an ASP.net world.



[...] to VoteCherry-Picking RoR Features for ASP.net (8/24/2008)Sunday, August 24, 2008 from spencerdillard.wordpress.com5. MS MVC does most of the organization for [...]
ASP.NET MVC Archived Blog Posts, Page 1
August 25, 2008
[...] public links >> plinqo Cherry-Picking RoR Features for ASP.net First saved by pruffing | 2 days [...]
Recent Faves Tagged With "plinqo" : MyNetFaves
September 20, 2008