开发者

Asp.net design patterns [closed]

Closed. This question is opinion-based. It is not currently accepting answers.

Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.

Closed 8 years ago.

开发者_StackOverflow中文版 Improve this question

I'm a junior developer, who knows the basics already and have some experience as well, but when it comes to building a project from ground up I'm useless in terms of writing a good maintainable code. I know there are tons of design patterns for this purpose, and as well I'm aware of the asp.net MVC3. Now, do I need to read asp.net design patterns books to be become a good architect for asp.net or should I concentrate on MVC as it is the new and better design pattern ? I have this impression that design patterns and MVC stand separately since MVC is "forced" design pattern on it's own. I need to clarify this for myself and appreciate all the answers ! Thanks.


I like Asp.Net Mvc much more than Web Forms because its easier to understand whats going on. The other thing is that mvc has much better "seperation of concern" that will help you building a good architecture. Its very clean, no asp.net controls no viewstate, no doPostBack().

You cold learn that using webcasts by phill haack and / or scott hanselman. They have many videos from different events like mix and other.

  • http://www.hanselman.com/
  • http://haacked.com/

Pattern /Techniques i prefer:

  • Repository Pattern
  • Dependencie Resolution (Ninject)
  • Mvc Scaffolding (a must!!)
  • Entity Framework Code First
  • Nuget Packages like (Elmah, Glimpse

Other good resources are:

  • http://asp.net/mvc
  • http://stackoverflow.com ;)


I would recommend to refer MVC sample applications and watch free videos. Design pattern, itself is a complex area. Just concentrate on MVC and try learning from many sample applications. Also look into Entity Framework 4.1.


Anyway MVC is must know, but I would suggest to start from the basics and learn such pattern categories like:

  • Behavioral patterns
  • Structure patterns
  • Creational patterns

Very good book with clean examples using C# is "C# 3.0 Design Patterns" by Judith Bishop


do I need to read asp.net design patterns books to be become a good architect for asp.net or should I concentrate on MVC as it is the new and better design pattern ?

Yes :) All kidding aside, since you say you are a junior developer, I would start by writing one or two MVC applications first (even if they will be throw away apps) so that you get to "feel the pain" that the patterns solve. Reading about patterns is a great complement to writing code but I would keep the focus (at least initially) on your coding skills.

There are a lot of things that you probably will need to learn, but take it slowly. Don't try all the patterns and tools at once. A great book to read about MVC is Steven Sanderson's Pro ASP.NET MVC 3 He includes a very good sample application that he builds little by little following good programming practices.


One thing to remember: "implementing design patterns" and "writing maintainable code" are two COMPLETELY different things. You can follow design patterns to the letter, and still end up with an unmaintainable mess of code:

  • lack of comments
  • lack of consistent naming
  • enormous functions with loads of nested IFs and loops
  • keeping old, no-longer-used objects in your codebase
  • sprinkling hard-coded, cross-dependent strings throughout your code
  • and 1000s of other ways to make your code a mess :)

Similarly, you can write solid, maintainable source code without ever having heard of the gang-of-four. In fact, inappropriate or gratuitous use of a design pattern can make your code notably less maintainable. An example that leaps to mind is Singleton: in many projects I've worked, developers use singletons ALL OVER THE PLACE, even when there's no need or value in doing so. In that case, every time I encounter one I need to go spelunking through the code looking for references to external resources, or expensive construction/initialization operations.

Unfortunately, I can't think of any specific good references for writing maintainable code right now (maybe some other SOers can chime in with recommendations). Hopefully you work in a good situation where you can get feedback from more senior devs (through code reviews, or less formal channels).

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜