ASP.NET MVC - Is it viable for small web outfits? - asp.net-mvc

I work for a small website company (couple of programmers, couple of designers). Currently we use ASP.NET website projects - this makes it easy for me to sort the programming out on my local machine, while the designers work directly on a development server and the 'on-the-fly' compilation allows them to see any changes made without having to compile and deploy the website (and all tied up with SVN).
I'd like to start using ASP.NET MVC for pretty much all the reasons that makes it different from Webforms (logical urls, no viewstate, more control over html, unit testing etc..) but don't want to make the dev process over complicated, so:
Any reasons you can't set MVC websites up as website projects instead of Apps so they don't have to be explicitly compiled throughout the dev process? (Our 'live' websites all use web compilation projects anyway).
Will this still allow unit testing?
Is there any other way of allowing the designers to develop MVC sites in the same way as they currently do? Note: They use Dreamweaver, so no Cassini development server.
Can anyone advise with any of the above (even if only to tell me my dev process makes no sense.. :)
Thanks.

ASP.NET MVC is a great platform no matter what type of project. If you already understand the basics of HTTP and how websites actually work ASP.NET MVC will be like the thing missing from your life. If you're used to the postback model of ASP.NET WebForms it may be a little harder to grasp at first but it's very easy to understate. It's basically a stateless model. Your controller is given some parameters, it writes back some HTML... end of story until the next request.
I don't think so, and I think the reason for this was to allow bin-deployable ASP.NET MVC projects. You can publish an ASP.NET MVC app straight from Visual Studio 2008 without the end server ever even having to know about ASP.NET MVC, as long as it has ASP.NET 3.5 (with SP1 I think)
ASP.NET MVC is all about unit testing, it's extremely flexible in this matter and even some of the design decisions behind ASP.NET MVC are based off allowing users to unit test their code. Scott Guthrie specifically names unit testing in the latest release of ASP.NET MVC (beta) http://weblogs.asp.net/scottgu/archive/2008/10/16/asp-net-mvc-beta-released.aspx#six
Any controls that work with ASP.NET WebForms will work with ASP.NET MVC as long as it does not rely on postback. If it does than you cannot use that control/code.
MVC is a proven design pattern for websites and even the very one you posted your question on is based on ASP.NET MVC and was built by only a few people and is now maintained by 1 (one) person (soon to be 2). I currently am using it for 3 private projects and I love it. I've seen the light and I will never go back to WebForms.
Resources:
Scott Guthrie's blog
Phil Haack's blog
Rob Conery's blog He has created an MVC Storefront demo over 25+ videos.
Scott Hanselman's blog
Stephen Walther's blog
PDC08 ASP.NET MVC Session Session was with Phil Haack and Jeff Atwood (creator of this site).
HTH!

I used to be an ASP.NET developer. Recently I started developing with Django and do so with one other developer remotely via SVN. I find that MVC frameworks make small projects even easier, and larger projects a lot less painful than oldschool ASP.NET did.
Templates are far easier to control and style than the web controls in ASP.NET. Separation of logic (beyond the code-behind methodology) makes it easier for more than one person to be working on different parts of the site at the same time. RESTful design centered around actions starts making a lot more sense after having to deal with ASP.NET page life cycle issues long enough. Also, the URL-driven routing and the ability to do reverse lookups means fewer hard coded links in your code, its easier to add new sections to your site, etc.
To answer some of your questions:
I'm not sure about live compilation, but its easy enough to write some simple deployment tools to automate this process.
Unit testing is often easier on an MVC framework thanks to actions in controllers compartmentalizing the logic much better.
ASP.NET MVC allows you to use webforms as the default template language, but I'd advise looking into cleaner templating languages such as NVelocity. Any HTML-centric templating system is going to be better than webforms because of how difficult it is to tame and style even simple aspects of web controls.

This site uses MVC. I think the team behind StackOverflow qualifies as a small shop. They have a lot of experience though. Still, considering how many people are involved (a few) and the number of servers, yeah, it's small. And it runs very well in my opinion.

Related

What is ASP.NET MVC about ?- is it just about URL's?

MVC frameworks in general?
Is it different from MVC in desktop GUI applications?
What exactly is it that makes it easier to test than WebForms ? (Can't you test Code Behind in a similar way to MVC controllers)
I have the impression that ASP.NET MVC is mostly about clean URL's - with controllers processing user input in the form of URLs.
A barbone web forms application in classic ASP for example is very different from the MVC concept. While ASP.NET Webforms with events and page-state goes more in an MVC direction as one thinks of it in a desktop GUI world.
How about trying Wikipedia?
Quoting: "Model–View–Controller (MVC) is a software architecture, currently considered an architectural pattern used in software engineering. The pattern isolates "domain logic" (the application logic for the user) from the user interface (input and presentation), permitting independent development, testing and maintenance of each (separation of concerns)".
So it helps making an application organized (because it imposes that you separate your business or domain logic [model] from all interface code [view]).
It also makes much easier to apply TDD.
And, speaking of Web MVC .NET frameworks (like ASP.NET MVC, Castle Monorail or OpenRASTA), they also normally allow:
Seeing web pages as they really are - stateless resources (instead of creating fake state retention, like the ASP.NET WebForms ViewState).
The existence of client-side programmers in your job that do not know (and probably don't want to know) anything about .NET.
Elegance (as opposed to spaghetti code, or, well, WebForms).
Nice URLs!!!
BTW: there are a LOT more benefits, and if you are unable to perceive them, I would recommend that you look beyond the .NET world. You'll notice that almost every other language/environment has at least one MVC framework available:
Python has Django.
Ruby has Ruby-On-Rails.
Java has Spring, Play.
PHP has CakePHP, Symfony.
And so forth...
Which clearly shows that MVC is an idea worth repeating, and a proven architectural pattern.

Is ASP.NET MVC a good platform?

I aim to try use DevExpress web server controls (which are awesome) in an ASP.NET MVC project (some articles I read on 'net seems to indicate the two can work well together).
I'm eager to start a new project using ASP.NET MVC, and I have been reading up a lot on ASP.NET MVC lately, but I'm not sure if I should invest a project in it. My concern is that it may turn out to be like LINQ to SQL, which is essentially been killed off since MS will not be providing updates.
Is ASP.NET MVC a viable solution to invest in my case?
Yes definitely ASP.NET MVC or any other MVC framework is worth learning. MVC pattern is all about seperation of concerns and helps you to keep your code clean.
If you like Devexpress control too much you could be disappointed because there is no server side control in ASP.NET MVC. But if you want to learn Web's underlying mechanism,HTML, Javascript , clean code, TDD ASP.NET MVC is a good way to go.
Learn first, experiment later
Asp.net MVC is a great development platform for building web applications, so it's definitely worth your time to learn it through and through.
But I suggest you first learn MVC framework and build at least one semi complex app with it and then start experimenting with mixing MVC with web forms controls. It is possible but as much you think you will gain you'll probably loose more. So I would be a bit reluctant and advise you not to match these. At least not on a Greenfield project.
In other words: presumably knowing Asp.net web forms would you suggest someone to heavy use dynamicly created user controls in their web pages if they're just about to learn the technology of Asp.net web forms? Probably not. Or mixing web forms with ASP pages on a greenfield project...
Instead try finding great either MVC-friendly server extensions or client-side libraries that will help you create rich web apps like ExtJS (I don't work for ExtJS llc, but I used the lib on a project in the past and liked it a lot). Using something like this you won't loose stuff from MVC and gain great user experience and rich functionality.
Seeing how you're asking the question on this site, I'd say YES!
DevExpress has a bunch of MVC specialized controls, that use Ajax to get data from the server via callbacks. You can see demos of the controls here:
http://mvc.devexpress.com.
I am not sure if you can use the web forms controls, my understanding is that you can't.
Also, regarding LinqToSql, you don't have to use that. I am using NHibernate for the data layer and it works very nice with MVC.
I worked with asp.net and web forms for more than 5 years and at least 1 year with the DevExpress controls for asp.net, but now I love MVC so much that I think I don't want to go back to the web forms anytime soon.
Hope this helped.

Justification for MVC?

I was wondering if someone could provide me with some answers. I've been asking to swap our internal apps to an MVC architecture for quite a while now. Rails was absolutely shot-down as a toy, Struts is just too huge for the apps we do, Django's name makes these old folks nervous (oil & gas industry) but finally, finally Microsoft has come out with MVC 1.0.
Since the Powers that Be are dead-set on using Microsoft technologies, I think I may be able to convince them to move our applications to an MVC pattern. Unfortunately, I can't come up with a good reason to swap to our forms-based structure to an MVC style.
Can anyone think of justification good enough to feed to my bosses? :-)
Do you have a good reason to switch? It sounds like you don't so I am wondering if you are switching for the sake of MVC itself which I would discourage you from doing.
ASP.NET MVC is helpful when you wish to have more control over the output and lifecyle of your application. Keep in mind that in many cases this means more work for you as the developer. MVC frameworks are good for sites that are not data-entry intensive - in other words if you handle a lot of form POSTs and process data out of those forms then ASP.NET MVC will actually create more work for you.
I don't mean to sound harsh but it seem strange to me that you want to switch to ASP.NET MVC but don't really know why.
There are a number of questions that address this in different ways:
Should I pursue ASP.NET WebForms or ASP.NET MVC
How to decide which is right, WebForms or MVC when doing ASP.NET
Traditional ASP .NET vs MVC
Biggest advantage to using ASP.Net MVC vs web forms
MVC Versus Web Forms
ASP.NET vs ASP.NET MVC
I think it's not a matter of "selling" MVC, but rather of understanding it's advantages.
also, you should seriously evaluate whether migrating an existing system to MVC will be cost effective.
however, MVC has many advantages - here are some from the top of my head:
separating control, data and presentation makes your application more maintainable
easier to make changes
after a relatively short learning curve, easier for other programmers to comprehend
better design means introducing new features is easier. try adding caching, form validation, etc when everything is mixed up...
an MVC system may be more testable (and therefor can be more reliable) - it's much easier to test your controllers than to test a spaghetti of data, control and presentation code.
I think that in this case the OP is looking for a pragmatic (profitable) reason to switch over to MVC, since most companies think that way.
The biggest advantage is that it is much easier to create unit tests for ASP.NET MVC applications. A good suite of unit tests can then serve as the foundation of a Continuous Integration process.
The bottomline for the powers to be is that you can create a build in a single step, simplifying deployment, creating installers, patches etc.
Rails and Django both follow the Model View Controller (MVC) pattern so sounds like you will just be creating a load of work for yourself. Why do YOU want to switch to ASP.NET MVC?
"Struts is just too huge for the apps we do"
In what way? Struts made even simple internal applications a breeze to develop in our company, once we had learned how it worked (which was quite quick). A few JSPs, a few Actions, backend database access done in JDBC via some simple DAOs, bundle it all up in a war with ant/maven and deploy. Done.
Also, fyi, keep Joel's advice in mind (Things You Should Never Do, Part I): avoid rewrite the code from scratch.

When and why should I consider asp.net MVC?

I've noticed a lot of talk about asp.net MVC lately, but I haven't come across a clear or compelling description of when, where or why I would want to use it over WebForms.
Let's say I wanted to build a small web application that allows a person to advertise some items online. The website will have 4 use cases:
Search adverts
View listings
View item
Place an advert
Let's assume:
I'm not particularly interested in unit testing my controller. The page will either render the list of items correctly, or it won't.
I am interested in more control over the HTML markup.
I'm not interested in using the latest buzz technology just for the sake of it.
I am interested in using the tool that is best suited to the job in terms of productivity, performance, maintainability & simplicity of the end solution.
I don't want to have to work around a bunch of nuances to get something simple to work.
So, my questions are thus:
What are the fundamental differences between the two models?
In which scenario is one better than the other?
What are the gotchas with asp.net MVC (I'm aware of the gotchas with WebForms)
For our sample app, what would I gain by using asp.net MVC instead of WebForms?
For our sample app, what would I lose by using asp.net MVC instead of WebForms?
Is it feasible to mix and match models within the same small application?
Thanks to anyone who spends the time to contribute an answer.
What are the fundamental differences between the two models?
WebForms try to mimic WinForms development by allowing you to reuse lots of pre-made controls, and by faking web application state via the hidden _VIEWSTATE mechanism.
MVC is a pattern designed to help you separate your data (Model), business logic (Controller) and presentation (View). It adheres more to the true nature of the web : RESTful URLs, stateless.
In which scenario is one better than the other?
In my opinion, for an intranet application making heavy usage of controls, WebForms can be useful at reducing development time, because thanks to the designer you can create your UI very quickly and let the framework manage the app's state automatically.
For any other project, especially a public website, even a small one, I think MVC is the way to go.
What are the gotchas with asp.net MVC (I'm aware of the gotchas with
WebForms)
I'd say there is some learning curve to fully understand the MVC pattern and its power. Also, since the framework is still in BETA you can expect the API to experience some minor changes before release.
Since JavaScript is not hidden from you in MVC, it would also require some time to learn if you're not familiar with it. jQuery greatly simplifies this though.
For our sample app, what would I gain by using asp.net MVC instead of
WebForms?
You'd gain better control over HTML markup and Javascript behavior, a cleaner separation of concerns and some easily testable codebase (even if you don't seem interested in unit testing it).
For our sample app, what would I lose by using asp.net MVC instead of
WebForms?
You'd lose the 'drag and drop' quick way of building your pages and the application state management.
Is it feasible to mix and match models within the same small
application?
In some ways, yes it seems.
I'd recommend watching this talk by Phil Haack, who gives a good overview of the framework and invites Jeff Atwood to talk about how he built StackOverflow with it.
He explains how SO is using some WebForms controls for CAPTCHAs which render themselves into the view.
The primary difference is that MVC is more like "regular" web development that the rest of the programming world uses, whereas standard ASP.NET was designed to make it brain-dead easy for Windows developers to become web developers. I learned web programming by learning Ruby on Rails, and MVC seems like it is becoming the .NET version of Rails.
MVC is much more oriented around standards compliance, unobtrusive javascript, and separation of concerns than regular ASP.NET. You'll need to understand how HTML and CSS work together. You'll learn a LOT more javascript as you master MVC. One of the biggest advantages of MVC to me is that you can use jQuery to do some amazing AJAX stuff easier and BETTER than you can in regular ASP.NET.
If you're just now learning web development then I strongly encourage you to learn MVC. You'll be able to transfer at least some of your new skills to other frameworks in the future.
If you're looking for which to learn to quickly get a web development job, then I'll have to strongly suggest ASP.NET.
Once MVC is RTM'd I think we will see a slow and steady adoption curve and as it matures MVC may become the primary framework for creating websites with ASP.NET. I hope so at least!
The biggest difference between ASPNET MVC and is WebForms is the lifecycle of an page, no difficult(unnecessary) postbacks, clean coding, enz.
There are no rules for that
???
REST-full website, Separation of logic
Design-time support, can't use third-party webcontrols
Please don't mix it together. If you really want to use the WebForms model you could use the MVP pattern, Billy McCafferty wrote exellent articles on that design pattern
I'm redesigning some of my applications from the MVP-pattern to MVC-pattern, not because MVC is better but I would like to use the newest techniques offered by MS(pattern itself is quite old).

Practical Application of MVC || When to use, or not use MVC

I have seen the ASP.NET community buzzing about MVC. I know the basics of its origin, and that there are many sites (unless I am mistaken, stack overflow itself) based on ASP.NET MVC.
From everything I have heard and read about MVC it seems to be the future of ASP.NET development. But since I don't usually dabble in .NET web development I am left wondering the following: when is it appropriate to use MVC and when is it not, and why? Examples of great (and terrible) use of MVC would be fascinating.
Though I realize there are other implementations of MVC view other languages like RoR I am more interested on its impact for .NET programmers.
If this has already been gone over, my apologies!
Here are my 2 cents about MVC for web applications. For the sort of GUI apps for which MVC was originally intended, "listener" code was required, so that the UI could be updated when events altered the model data.
In MVC for the web this is unnecessary, you get your listener for free: the web server, and the HTTP request IS the event. So really MVC for the web should be even simpler. Indeed, it could be boiled down to the Mediator pattern, where the Controller mediates between the model and the view.
There are two things that there is a lot of confusion about. Regardless of conventional "wisdom":
Frameworks != MVC
Database Data != "Model"
"Full stack" web development frameworks typically add lots of features, and may or may not be MVC-oriented at their core. One of the features many frameworks add is database access or object relational mapping functionality, and because frameworks and MVC get confused, subsequently database data and the model facet of MVC also get confused. The model can generally be viewed as the underlying data for the application, but it does NOT have to come from a database. A good example might be a wiki, where the underlying model/data consists of file revision data, for instance, from RCS.
Hope this helps and I'm sure others will have plenty to add.
I would say one very compelling scenario to use MVC is if you have a group of experienced .NET developers who dont have experience with WebForms.
Coming from that situation myself (very little web experience) I found it I was much more productive and comfortable using MVC over WebForms.
I found it very hard to pickup WebForms due to the aforementioned abstraction - (I think proof of WebForms complexity is I have never met anyone who I would consider a WebForms "guru" i.e. knows the Page Lifecycle off by heart/Data Binding back-to-front etc.).
Using MVC actually allowed me to use my .NET and software experience without needing to heavily invest in learning the WebForms framework. Not only that but I got a much better understanding of HTTP, and this I think would allow higher quality solutions.
IMHO MVC allows you to factor code much better than WebForms, so I think developers with lots of "patterns" experience will be more comfortable in MVC.
ASP.NET MVC isn't the future of ASP.NET development it is just a new way of developing websites with ASP.NET. Microsoft have made it clear they will continue supporting and improving both WebForms and MVC in the future.
I cannot think of any websites, were it would not be appropriate to use MVC. You could also argue the same for WebForms.
Whether you choose one over the other is a personal choice, and would depend on the development team's experience and preferences.
I personally would never go back to WebForms development after using MVC on several big projects. WebForms in my opinion places an unnecessary abstraction layer over http and html. For quick prototypes you can get something cobbled together quicker with WebForms, but after that the complication of the abstraction makes things harder rather than easier. The only compelling reason to use WebForms in my opinion is the rich level of 3rd party controls that are currently available. But you can mix WebForms and MVC, so its easy enough to get the best of both worlds.
I work in a shop that has both ASP.NET and MVC applications. I think originally I was biased toward web forms because I worked with them from several years, but after working on a few MVC projects I prefer it.
Something to consider, however, is that if you have a team of experienced web form developers initial progress in an MVC application will be a slower because of the learning curve, so if the timeline for a project is very tight it might not be the best time to transition.
Aside from that I can't think of any situations where I'd prefer web forms over MVC at this point.
Based on my own experience, I can tell you that if you don't have any Winforms or Webforms background, you may feel more comfortable under the MVC umbrella because you are not "expecting" anything from the ASP.NET Webforms world.
On the other side, as a recommendation, I encourage you to check out other MVC frameworks like Django or RoR that are more mature to "be water" on the MVC way of thinking. I'm happy with ASP.NET MVC but looking other solutions helps you to understand better the paradigm behind the framework.

Resources