Best practices in building ASP.NET application - asp.net

We are building an ASP.NET application (with C#.net as language) and will be hosting on Windows Server 2003 Operating System with SQL Server 2008 as database.
We are planning to implement the best practices in writing code, dividing the application into logical blocks, services etc.
Would you please guide me on this, if you have an idea?
If would be great if you could also provide a reference document or web references (If needed).
Many Thanks,
Regards,
Venkat.

This isn't what you want to hear, but your best bet might be to bring on a senior asp.net guy who has a lot of experience and put him in charge of this.
But that's an extremely broad question, Venkat. Maybe if you could narrow it down a bit more we could provide a more useful answer.
I would perhaps recommend one book called Framework Design Guidelines, which is published by Microsoft Press. It goes into a lot of best practices on writing code, naming conventions, how to design classes, etc. And there are dialogues in there between Microsoft's top language guys. Sometimes they disagree, and that's always interesting.
But that's just one piece of the puzzle. I could talk for hours about methodologies, architectural patterns, object oriented theory, seperation of concerns, etc. As stated, your question covers all that ground.

Related

Microsoft WebMatrix: what is it?

I'm a little confused about new Microsoft products.
I'm a classic webform Asp.Net developer. I know exists also Asp.Net MVC with a different approach based on Mvc pattern.
Now, i know exists also WebMatrix that uses new Razor "notation".
Can someone explain me what are the main difference between that "technology" ? When use WebMatrix, when WebForm ?
Thanks!
Webmatrix is a platform that integrates a variety of recently released technologies such as IIS Express, Asp.Net Webforms, Razor, SQL Express etc. I guess from what I have been reading it's a way that eases the barrier to entry, for non-MS developers, into the MS world. In addition you can also use code your site in PHP and use a variety of open source tools for developing web sites. To directly answer your question, in you planning on creating a complex web application, WebMatrix may not be the solution you're looking for.
As a reference, I suggest reading through Scott Gu's Introduction to Webmatrix
WebMatrix will be able to take
advantage of these technologies to
facilitate a simplified web
development workload that is useful
beyond professional development
scenarios – and which enables even
more developers to be able to learn
and take advantage of ASP.NET for a
wider variety of scenarios on the web.
If you are a professional developer
who has spent years with .NET you will
likely look at the below steps and
think – this scenario is so basic -
you need to understand so much more
than just this to build a “real”
application. What about encapsulated
business logic, data access layers,
ORMs, etc? Well, if you are building
a critical business application that
you want to be maintainable for years
then you do need to understand and
think about these scenarios.
Imagine, though, that you are trying
to teach a friend or one of your
children how to build their first
simple application – and they are new
to programming. Variables,
if-statements, loops, and plain old
HTML are still concepts they are
likely grappling with. Classes and
objects are concepts they haven’t even
heard of yet. Helping them get a
scenario like below up and running
quickly (without requiring them to
master lots of new concepts and steps)
will make it much more likely that
they’ll be successful – and hopefully
cause them to want to continue to
learn more.
One of the things we are trying to-do
with WebMatrix is reach an audience
who might eventually be able to be
advanced VS/.NET developers – but who
find the first learning step today too
daunting, and who struggle to get
started.
If someone is still interested: a pretty good lessons here http://habrahabr.ru/company/microsoft/blog/136004/ . This link is for those, who understand russian.
Shortly speaking WebMatrix allows you to conveniently mix up C# server code and html (this mixing is provided by simple Razor sytax). Also in WbeMatrix 2.0(beta version now) is provided full IntelliSense for html/css/c# code.

Significant advantages of ASP.NET MVC

I'm slowly getting into MVC, but it's still relatively new to me. From what I've discovered by doing a few tutorials, MVC provides an interface for communication between the database and the website and in general allows for better organization of the code.
Are there other significant advantages to using an MVC structure? What would be an example of a time when you wouldn't want to user MVC, even if you are communicating with a database?
Thank you!
Technically speaking, MVC has nothing to do with whether or not an application uses a database. MVC is about separating concerns so that the things that represent business concerns and logic [the models] are separated from how the UI is displayed [the views]. It doesn't matter whether or not your models are stored in a database, on the filesystem, in memory, or not even persisted at all.
As for when would you NOT want to use MVC, that's harder to say. MVC is about separating concerns to simplify the construction and management of a software system. If you don't need those benefits, or if you get greater benefits through a different pattern (for instance, if you have a team that's highly skilled in a non-MVC based framework), then don't use it. It's certainly possible to build good software without using the MVC pattern, the pattern just helps.
The pro/con list in this blog may help you understand when MVC makes the most sense to use.
http://www.ytechie.com/2008/10/aspnet-mvc-pros-and-cons.html
You can take a look at this video: Choosing the right programming model.
Since you indicated you're a beginner with MVC I suggest you take a look at these informative tutorials.

ASP.NET Web-Application Architectures / Patterns

Does anybody knows good, short and slim tutorials, which describe actual/modern web-application architectures / patterns (especially for ASP.NET based (classic and MVC) applications (maybe also with embedded Silverlight components) ?
How would you you design today an ASP.NET application which uses different datasources (databases, services,...) ?
Background: I has been away a couple of years writing web applications, and I want to start now again. So at the moment I am a little bit unsure, how to take off and find the right starting point.
If you're interested in MVC I'd suggest starting out with the offical MS tutorials:
http://www.asp.net/mvc/tutorials
There happens to be an upcoming free online conference on ASP .NET MVC that may interest you: http://mvcconf.com/
Check out Sharp Architecture:
http://wiki.sharparchitecture.net
there are some articles that describe how & why it's architected the way it is that might help you with your project.
You can take reference of following -
http://mvcmusicstore.codeplex.com/
http://nerddinner.codeplex.com/
You have many questions embedded in one :)
short and slim tutorials = For getting architectures/patterns explanation is always bit more extensive since original developer/reviewer explains the design decisions or thought process of selection of components used.
I would like to recommend P&P's Application Architecture Guide (http://msdn.microsoft.com/en-us/library/ff650706.aspx) for reference architectures.
Real World Coding Examples: There are lot many on GitHub. It really depends on the type of app you are taken for development and business domain.
Some pointers: http://www.asp.net/web-forms/samples, NopCommerce,http://www.magelia.org/,www.teamlab.com etc. There is lot of good codebase which is working and available on GitHub etc.
PS: Start with www.asp.net Best resource!
Hope this helps.

Learning Web Development starting with ASP.NET MVC

I have been working with C# for past four years at the enterprise level. Now, I have taken a decision of moving to Web side of the things. Since I am well versed with C# and WCF I naturally zeroed in on ASP.NET as I need not learn a new Programming language. Learning just the Web Framework will suffice.
I have read a lot regarding MVC, so starting out with MVC 2.
My Question is Will I face any roadblocks if I learn MVC without learning Web Forms? Keeping in mind that this is my first foray into Web Development?
Looking forward to some good suggestions.
I was in your exact same position. The only problems you may have is wrapping your head around postbacks and what tha means. Having said that, MVC2 will teach you how to write better code instead of the typical spaghetti that comes asociated with webforms.
If you're new to MVC2 I'd recommend buying Wrox Professional ASP.NET MVC2 from writer Scott Hanselman.
Learning web development these days is hard as you need to be an expert on so many different things!
You need to learn HTML/CSS/JavaScript(ie, JQuery)/Json regardless of the server side framework you are using if you are creating “rich” web applications.
I would say starting with ASP.NET MVC is not a bad option before moving onto ASP.NET Web Forms. You are likely to hit both going forward, but as ASP.NET MVC does not hide what’s going on so much, I think it may be a better start.
However if you just wish to create simple forms on the web, it is hard to beat ASP.NET Web Forms, but as soon as you wish to do something more advanced, the Web Forms complex page cycle will give you pain.
If you're looking to apply your web skills to enterprise environments, you'd probably find a lot of environments still leveraging Web Forms. Outside of that, I can't imagine it would really hurt you that much.
The bigger thing about web development is getting familiar with HTML/CSS/JavaScript(ie, JQuery). The skills learned there are applicable to either environment. You'd probably be able so switch back end frameworks rather painlessly as long as you're used to c# and all the web stuff previously mentioned.
I think it depends on what type of applications you are going to be developing. I believe web forms would be easier for you to learn with the background you already have in WCF. But it might not be worth it if the applications you are developing are better suited for MVC rather than web forms.
My recommendation would be to determine what type of applications you are going to be developing and then look at the strengths and weakness's of each and then determine which one you are going to focus on.
You most probably won't. There are some concepts that belong to the web-application environment (session, caching, etc) that are common but you'd have to learn about them anyway. They are two separate frameworks so nothing very specific about one of them could help you with the other.
You will undoubtedly run into issues when knowing a "new" way of doing things without having been brought up in the "old" way of doing things. It's unavoidable, really. I'd suggest learning the basics of WebForms code if possible, if for no other reason than to be able to trudge through it when necessary. Of course, if you find yourself in the position of having to support a WebForms application, you'll learn by doing just like anything else.
This question reminds me of my early days in .NET (which were the very early days of .NET in general) and trying to find assistance with various issues. I was an entry level developer, hitting up forums and such with questions. Everywhere I went, people weren't really adopting .NET just yet. They were all old Windows platform developers, whereas .NET was my first Windows development (I was all UNIX/Linux in school). Invariably, nearly every question I asked was answered with something suggesting that I "just use COM." Of course, I wasn't familiar with this. It was "the old way" and I was using "the new way."
It was difficult to work past that, and you'll likely face the same issue here. Basically, when people have made a career out of doing something the one single way they know how, they tend to expect everyone else to know it as well and will cling tightly to it as their bread and butter. You can be better than that, but it'll require patience :)
I assume that your development experience included Windows Forms. In terms of the transition from Windows Forms to ASP.NET WebForms, there's no doubt that would be an easier transition. Whether that would be the best transition is another question. And I believe the answer is without a doubt, no.
MVC allows you to gain an understanding of the way the Web works. Understanding GET and POST, Requests and Responses, not to mention HTML, CSS, JavaScript, et al.
I would not hesitate to recommend MVC.
I don't understand why you don't want to learn Web Forms. Learning Web Forms is just like learning abc's. You'll learn it as you go along with MVC. My suggestion is, Just go with the flow in your learning of MVC and you'll be surprise that you're already learning Web Forms.

ASP.NET vs SharePoint

For a developer who likes working in ASP.NET/Web forms, would anyone recommend going towards a SharePoint shop? Will I be able to keep up with latest in ASP.NET, or is SharePoint a different world? I really like ASP.NET, but have an opportunity with SharePoint development. Is the big change worth it on the tech/skillset end?
UPDATE: I think it's better to stick with web forms, if you have a choice. SharePoint seems to be tougher to develop[in terms of what you expect out of regular ASP.NET]/deploy/style/debug. Why should good ASP.NET devs go to SharePoint if they don't need to?
Your ASP.Net knowledge will help you understand some of Sharepoint, since it is based on some of the same technologies as ASP.Net.
On the negative side:
Sharepoint has a steep learning curve
Some developers hate it
On the positive side
For the right scenario, you can deliver business value much faster than custom development
Atleast in our market a Sharepoint expert will be better paid than someone who only knows ASP.net
As someone who's been on the sharepoint train for a few years now, I'd say you'd be crazy NOT to take the opportunity. SharePoint is firmly based on asp.net and there is plenty of crossover. In fact, ASP.NET 2.0 design was large driven by the needs of WSS 3.0 - namely webparts and the system.web.hosting virtualization aspects. You will feel extremely comfortable when developing. Go for it.
-Oisin
I've been working in the SharePoint world for a good year now and I went into it head first not knowing any ASP.NET. Now that I'm getting time to teach myselfs some ASP.NET and learning the more webby concepts things in SharePoint are making a bit more sense. Although a working knowledge in ASP.NET isn't strictly needed in day to day SharePoint, at least not all of SharePoint, it is useful. I just don't find myself doing that much ASP.NET.
However that doesn't mean that you won't. There is certainly scope for it in producing SharePoint pages and modifying a site through the master pages ect. Or even web part development. SharePoint has lots of developer entry points and they vary in exposure to the underlying ASP.NET. So it really does depend on what you'll be doing.
SharePoint is different world that based on ASP.NET. You shouldn't pay attention on this. You can learn new ASP.NET features in any time you wish. I think you should change your mind to try to solve problems needed for someones business and choose what platforms or languages to learn basing on this. No matter SharePoint or ASP.NET you can be as good as you wish in any of them.
Please don't think that I am trying to say that you will not be able to use your ASP.NET experience as a SharePoint developer. But you should understand that there will be a different world with its own rules and high level scenarios, that can be completely different than in ASP.NET. (for example Data Access scenarios has requires another model of thinking).
SharePoint is based on ASP.NET. You can use all ASP.NET features you're accustomed to in SharePoint.
If you go with SP, plan on doing a lot more pointing and clicking and a lot less writing code. The development aspect is okay, but there's a lot to learn using the object model, CAML and some serious config.
If you like software development, writing code, being creative with your skills, I would stick with ASP.Net.
You'll also find yourself dealing with the business a lot more.

Resources