My experience with FubuMVC so far

I’ve been checking out FubuMVC with a little hobby project. Why? Honestly, just curiosity. I don’t have much problem getting stuff done in Asp.NET MVC, but I love StructureMap, so was just curious how the creator of that would envision a MVC framework. Here are my thoughts so far. This is not me trying to post a end-all / be-all post about FubuMVC, just detailing a little of my experiences so far.

 

The good

There’s lots to love about FubuMVC. Lets start with organization. I absolutely hate the “Controllers / Models / Views” folder layout that the Asp.NET MVC project template uses. That’d be like designing a library by making the folders “Classes / Interfaces / Enums”. So out of the gate FubuMVC is directing you to something better, I feel. I opted for Namespace-per-feature. Granted, I should be able to put controllers and models wherever in a Asp.NET MVC project (not sure on Views, but probably), but with the template doing that, it’s going to be hard to do that outside of greenfield development.

I also really enjoy the behavior chains pattern. They work well and are easy to implement. I don’t know how much they differ from similar features in Asp.NET MVC like Handlers (and to an extent, ActionResults), but they’re still nice.

It took me a while to fully grok it, and while I’m not 100% there, I really dig the way routes are handled. In Asp.NET MVC, you define a pattern, which then tries to match controller actions. In FubuMVC, that’s turned around – you define your actions, then your convention for how actions are discovered, and those are converted to routes. It feels much more intentional and direct, and after using it some, it makes Asp.NET MVC’s way feel bass ackwards.

Everything, and I mean everything, is extensible. You can define your own conventions for pretty much everything. It has some great, sensible conventions baked in that will probably suit like 90% of people, and if nothing else, get you going out of the door. But when you’re ready for something different, you got the hooks to do it, typically by implementing a simple interface then telling StructureMap to pick it up.

One of the best features thought, is their diagnostics. Your site will have a “/_fubu” path. Opening it up will show you all your routes and the behavior chains wrapped around them. A great way to see why your routes aren’t working, what chains are getting applied, and a good early warning system for issues. There’s a lot more there, but I haven’t had a chance to dig into it all yet. But I love what I see. So few tools put support to the forefront like this.

 

The bad

FubuMVC bills itself as “The MVC framework that gets out of your way”. Well, and this isn’t really a fair statement but I’ll say it anyways – often times it feels like it’s out of my way because there’s nothing there. It still has some areas that left me very frustrated and annoyed.

The documentation is just sad. Their own docs are woefully incomplete with many sections left empty. And some of their examples do not seem to work as advertised. One that sticks out was their “asset pipeline”. It’s what you use to include CSS and Javascript files. There’s the very nice Bundles features of Asp.NET MVC, so I was looking for the FubuMVC alternative, and this was it. However, I cannot find a way to get it work. If I just want it to spit out the per-file link and script tags, it’s fine. But when I tried to use a combination, following what’s on their documentation, it would not work. I did not get an error (even with the option to show a YSOD turned on), and nothing gets emitted. It felt very black-box. I found a post on the FubuMVC google groups page with the same issue, with no response.

The Razor story in FubuMVC is miserable. I feel it should just be pulled. From the docs, you’ll think you can have a rewarding experience with it, but you just can’t. I followed the instructions, then had to tweak things to work with the latest release of Razor. I could not get intellisense working, which makes developing Views extremely cumbersome and “guess-and-test”. On top of that, a lot of Razor is built on the Html helpers, which will not work in FubuMVC. I assume full Razor support is possible, but it’s probably not worth it, due to how Razor was unfortunately designed (lots of static helpers, dependencies on HttpContext, etc). I think the better path is to ditch Razor altogether, and have them fully embrace and support a view engine. Perhaps Spark is that view engine? I understand FubuMVC is trying to stay open and allow people to pick their own, but seeing Razor is tempting, and while it’s not directly FubuMVC’s fault, it leaves with an altogether underwhelming experience that made me want to go back to Asp.NET MVC. Do not use Razor if you’re going to use FubuMVC. The FubuMVC examples though show returning strings of HTML, and that’s not really going to work. So I feel lost – unless the answer from the team is indeed “use Spark”.

I still have no idea how to render a partial view (or an action) with Razor, passing down a submodel. I probably shouldn’t be doing that anyways, as I thought of a better design for what I wanted using knockout templates, but it was still very frustrating. I can’t find anything in the documentation about how to do that. Probably because it all hinges on what view engine you use, and how much support it has.

 

Caveats

I don’t really like saying negative things, especially without giving the full context. So here’s some caveats I want to add in addition to the troubles I faced.

For one, I didn’t ask for help. There’s the aforementioned FubuMVC google group, that the FubuMVC developers seem to be responsive on. I was able to usually find a post there about my issue, but there was no good resolution. Still, I could’ve reached out more to make sure I’m not making newbie mistakes with easy answers.

Also, FubuMVC goes to version 1.0 in January (or that’s at least the plan). This is still a product in Alpha/Beta stage or some such. One of the things I know is coming with 1.0 is real documentation. Jeremy Miller has kinda a reputation for releasing a great product with poor docs (StructureMap), but with StructureMap I never ran into an issue I couldn’t solve with a little GoogleFu. Hopefully with 1.0 some of my issues get resolved.

Then the last caveat, that I’ve already mentioned – this is just a post of my experiences so far. I’m not saying there’s no good and easy way to do bundling and minification of CSS files in FubuMVC, for example. Just that I couldn’t get it to work after banging away for a few hours (or completely rolling my own solution). That goes for most of my “bad” notes.

 

Final thoughts

FubuMVC has a lot of promise. What’s there is mostly great, it’s what’s not there that hurts it the most (especially when compared to Asp.NET MVC). If you’re looking to start a new project for your business – I hate to say it, but my opinion is to stick with Asp.NET MVC. You’ll get things done faster, and have more resources available to you. If you’re doing a hobby project and want to learn something new…I’d probably recommend to wait until FubuMVC 1.0 comes, and see what it holds at that time. It has a lot of promise, and I think it’s headed in a great direction. Just didn’t feel it was ready for “primetime” yet. Even then though, just stay away from Razor – from what I’ve read on their group, unless someone champions it on themselves, the Razor story in FubuMVC will always be lackluster. Which is a shame, because I really like that syntax.

6 comments:

Corey Kaylor said...

Good feedback. Seeing that I am the author of FubuMVC's Razor support and do not use it myself probably speaks to why there is friction. However, some of what you said just isn't accurate. The tooling support works fine, so long as you "play ball" with the assumptions that were made on the tooling side. Referencing unneeded assemblies, placing configuration in the web.config that aren't needed. As for partials this.Partial(model) would get you what you're looking for. Unfortunately the other Include methods are an ugly remnant from RazorEngine's implementation and tend to confuse things. I *may* support them due to the mentioned confusion, but I didn't feel it was the "fubu way" of doing things.

On a separate note, I would look at behaviors a bit more or post questions to the discussion group. There's a lot of power here and the comparison to Handlers makes me think you should give it a second look.

Thanks for the constructive criticism. We'll do our best to remove the friction, and heck if we don't get to it fast enough we're very willing to take contributions from the community. ;)

Unknown said...

Thanks for the comment! After hearing Jeremy say that everyone pretty much uses Spark, I'm going to give that a whirl next.

That being said - have you tested the tooling in VS2012 with the latest binaries? I followed the steps in the docs, and running WinMerge on my web.config and the one in the docs, the only differences are WebPages.Razor is now 2.0, and Core, Web.Mvc, etc are 4.0. I've added references to Web.WebPages and Web.Mvc in my project as well. I've posted my web.config here: https://gist.github.com/590c869de79a32b88071 . The project itself is https://github.com/robertsimmons/collect , but I can understand if you don't want to go through the work. Especially since I'm going to try Spark anyways.

I really like behaviors, and figured there was more to it than what I saw at the get-go. As I said, this was just experiences so far, not meant to be a "I am now a FubuMVC master!" post by any stretch of the imagination.

Using this.Partial(model) gave me a "no behavior" error, so I'll continue to dig on that just for curiosity. Need to learn more about behaviors anyways, right? :)

Corey Kaylor said...

I have not tried in 2012, but I will make a point to sometime this week. Look in the discussion group for "actionless views" if that's what you're looking for. this.Partial(model) essentially does a controller / behavior chain for model (input model). An actionless view makes controller / chain unnecessary.

Corey Kaylor said...

This might possibly help as well. *I* haven't tested yet. http://stackoverflow.com/questions/10368545/get-razor-intellisense-in-library-project

Corey Kaylor said...

Some comments on Razor w/ VS2012

http://coreykaylor.com/blog/2012/12/08/getting-started-with-fubumvc-razor-on-vs-2012/

Anonymous said...

Take a look at my open-source routing framework for .NET: JuniorRoute.

http://projects.nathanalden.com/JuniorRoute

I believe JuniorRoute is superior to all other .NET MVC frameworks in several key areas. I encourage those of you interested in alternatives to ASP.NET MVC's heavyweight design to take a look at JuniorRoute. I actively maintain it and it has great documentation and even Visual Studio project templates.

Designed by Posicionamiento Web | Bloggerized by GosuBlogger