开发者

Question About ASP.NET MVC vs. ASP.NET Web Froms

开发者 https://www.devze.com 2023-01-31 05:09 出处:网络
I\'m a junior programmer, i do not get the concept of MVC! My method of coding is seperating my application design into 3 layers:

I'm a junior programmer, i do not get the concept of MVC! My method of coding is seperating my application design into 3 layers:

Presentation Layer Business Layer Data Access Layer

I find it very practical to 开发者_C百科a junior developer or at least to me, so i do not really get the point of MVC since i believe MVC just tries to separate logic from UI. Right?

I'm confused can you please give any advice!

Any help will appreciated...

I decided to have this book to help me have a better idea on code design:

http://www.amazon.com/Professional-ASP-NET-Design-Patterns-Millett/dp/0470292784/ref=sr_1_1?ie=UTF8&qid=1292836936&sr=8-1

Note: i also decided to start learning about TDD.

QUESTION: Is breaking my code design into 3 layers (presentation, dal and business) meets MVC concept?


i was quite a late 'convert' to mvc, after having been both a classic asp and webforms developer for over 10 years. however, about 18 months ago, a project came along that our management team decided would be a good self contained project to trial mvc on. I was tasked with managing the project. I'll admit that i was VERY sceptical as we had a large collaterol of components built for webforms as well as our own 'mini framework' for webforms projects.

imagine my surprise when I slowly found that being closer to the metal with the mvc paradigm was actually a more productive process. soon, i even began to question whether to go webforms or mvc on other new projects that were starting up. the beauty was that our webforms projects used the 3 layers approach that you mention and for us, it was quite easy to switch out the webforms portion and slot our BLL/DAL into place and use within the mvc project.

The long and the short of it is that it'll take time to get up to speed on the concepts of mvc but thankfully, there are many great books and tutorials out there:

http://nerddinner.codeplex.com/

http://blog.stevensanderson.com/

http://www.amazon.com/ASP-NET-Framework-Second-Experts-Voice/dp/1430228865/ref=pd_sim_b_2

i'd recommend the steven sanderson book, if it's the only one you ever look at. it ties together a very comprehensive walk thro on many core concepts, leading to a very detailed understanding of 'how it all works' by the end of the piece.

In short, no, designing with 3 layers doesn't = mvc. however, if you're worried about losing the knowledge and core functionality that you've built in your 3 layer approach, you needn't be. mvc and the BLL/DAL can work together just wonderfully. there is a fear when moving from webforms that you lose all the previous dpmain logic - in short, they happily merge/co-exist and it's entirely possible to still have part of the team working on the business logic whilst another part deals exclusively with the mvc implementation of that.

I was going to drone on about the excellent jquery integration - but that's a tale for another day :)


I suggest you start by viewing this video: MVC or Webforms - Choosing the Right Programming Model.

If you decide to go for MVC, then simply take a look at all the tutorials here: http://www.asp.net/mvc.


Since you mentioned TDD, I think this might be the best reason to go for MVC rather than web forms.

MVC is much better suited to TDD since it allows interaction to be tested with unit testing framework. I think this book is a good start on TDD with MVC


MVC can mean almost anything depending on what scenario you're talking about.

In ASP.NET (not MVC), you make pages that basically contain both the logic and the view for it. When a an aspx page loads, the "code-behind" (logic) is executed and binds data to the view to display it. This is repeated, all the time.

In ASP.NET MVC, you define controllers which, in turn, contain "actions" (methods) that usually build up objects called view models. The view models contain the data that the view will use to display. This is in a way equivalent to data binding in ASP.NET.

ASP.NET MVC uses web forms for its views by default but this can relatively easily be changed to another view engine.

So to answer your final question, ASP.NET MVC is a reasonable choice if you want to split the application up into "layers". ASP.NET MVC is also a good choice if you want good testability as that is one of the main problems with old ASP.NET.

0

精彩评论

暂无评论...
验证码 换一张
取 消