views:

117

answers:

5

This application I'm tasked with is basically a CRUD system for what will likely amount to about a dozen tables.

The technology is likely ASP.NET WebForms + Ajax Ctrl Toolkit + jQuery on the front side, and SQL Server on the backside.

This app will likely never be used by more than 10-20 users at a time as its a single-tenant system; however, at some point we may want to make it a multi-tenant system and would like to keep impact minimal for doing that.

My question to you bright folks, is this: Should I

  1. Build this as a simple 2-tier web application, where the ASP.NET WebForms talk directly to the business objects/layer which deal with data persistance in SQL Server through stored procedures (and maybe some Linq2SQL)?

  2. Build an n-tier application, in which the ASP.NET WebApp talks to a WCF service, that handles minipulating the business objects/layer which deal with data persistance in SQL Server through stored procedures (and maybe some Linq2SQL)??

  3. Some additional option, which I haven't thought of?

A more simple way to ask my question, is should I build a 2-tier app, or a 3-tier app? I am leaning toward a 2-tier since its simple, but maybe since the long term goal is to be multi-tenant, that a 3-tier WCF approach might be wise?

update

I appreciate the recommendations for ASP.NET MVC and I will investigate that path; however, any links to using MVC and WCF specifically would be helpful in choosing a final answer.

+5  A: 

Since it is basically a CRUD system, you might want to go with ASP.NET MVC. It will create a clear seperation of concerns right out of the box. And hopefully using Linq2SQL it will create your Views for you. Here you'll find a quick video of a simple CRUD application.

Yuriy Faktorovich
I'm open to MVC, but I've never used it before and I'm not sure this is the project to learn, I'm pretty battle hardened with WebForms and I understand MVC is much different. I'm going to watch the video and see if I think I can pick it up.
Nate Bross
+1 I would definitely recommend MVC over WebForms
AdamRalph
So based on the link you posted, it looks like you recommend a 2-tier webapp approach, using MVC instead of Webforms?
Nate Bross
Yes. The biggest thing being separating the UI from the business logic.
Yuriy Faktorovich
And you recommend the 2-tier approach instead of a 3 or n tier approach?
Nate Bross
Sounds like the application is simple enough to be UI, business logic, Data Layer.
Yuriy Faktorovich
That seems to be 3-ter, bu from your answer it looks more like you are advocating for 2-tier? Am I wrong? I see the same 3 areas you list as seperate tiers, is that correct?
Nate Bross
I thought the Linq2SQL would be the data layer, with that my answer is 3 tiers.
Yuriy Faktorovich
+1  A: 

My suggestion would be to go with n-tier/MVC approach just to keep things flexible..you never know in what way you might be required to extend the system later..should such a day come, you should not have to redesign your app

Aadith
Do you have any resources on using MVC with WCF? I get WebForms, but I'm not sure I "get" MVC, I understand basically how it works..
Nate Bross
MVC is just a concept...more of a design pattern...I'm sure there should be enough resources out there on the internet for MVC..just read on it...if you are like me and have time, you might want to read on some framework like Struts that is based on MVC...that would serve as a case study and would help you in getting a better understanding..and note that, struts is a framework for java web development..nevertheless, the underling fundamental concepts should help you in gaining perspective on MVC...i do not know enough about WCF to say anything about it.
Aadith
+1  A: 

If all you're doing is writing a CRUD system against a database, you could set one up within a week using Dynamic Data (I'm suggesting this without knowing much of all of the details of the system).

Use MVC for greater flexibility.

Jon Erickson
Dynamic Data instea of WCF? There is going to be some business logic, but in the grand scheme of things it wont be all that much.
Nate Bross
I agree, but I'm throwing it out there without knowing if there will be any business logic. Once you start having some complicated logic I would suggest NOT using dynamic data. =)
Jon Erickson
Dynamic Data builds on top of EF and LINQ to SQL, and is quite easy to extend with custom logic where needed - Brad Abrams talks through this in his "Business apps with RIA services" series, espeically here: http://blogs.msdn.com/brada/archive/2009/08/05/business-apps-example-for-silverlight-3-rtm-and-net-ria-services-july-update-asp-net-dynamic-data.aspx
Zhaph - Ben Duguid
+1  A: 

Please!! Go 2-tier (MVC or not).

Why add the complexity just in case? It will add time and effort to the project with no benefits.

Later, if the app is super-successful (it must be really, really, super duper successful) you will have the money and resources to re-architect it.

Edit: added explanation asked in comments:
N-tier refers to the possibility to run the app in different servers (or in the same server, but each on their own process):

  • One (or multiple) web servers running IIS
  • One (or multiple) servers running WCF
  • DB server

With 2-tier you have all the app running in the same server (and process), you can have the DB in a separate server.

You can easily have a 2-tier approach, but with separations of concerns having:

  • One assembly (VS project) with the DB access (if you use Linq2SQL it will typically have the DataContext)
  • One assembly with the business logic. This ones talks to the DB access and return List( of T) or IQueryable objects
  • The front-end (could be anything) that talk to the business logic.

If you later decide to change the front-end, you change only this project, and retain the DB access layer and business logic.

Eduardo Molteni
How is a 3 tier approach more complexity? Separating out persistence from domain logic often makes things much simpler (if you use a decent ORM).
SnOrfus
I like the KISS idea here, but I'm not sure how to do a good seperation of concerns in a 2-tier approach, is it possible?
Nate Bross
You can separate the domain logic and persistance in its own assembly without going n-tier
Eduardo Molteni
@Nate: you can separate concerns perfectly into different assemblys (if even necessary) and maintain the project 2-tier. I'm so emphatic in my point because I'm still maintaining a n-tier app, who never really needed it, but we do it "just for the flexibility". Nonsense.
Eduardo Molteni
Could you explain in a bit more detal about keeping seperate assembies (aka VS Projects) and only going 2-tier? I guess I see i as n-tier once seperate out the different aspects. I'm all for KISS, but I would like to keep things seperate, so if I go webforms, I can easily switch to MVC, or Silverligt or whatver down the road.
Nate Bross
Nate: edited the answer explaining a little bit more. Is it clear?
Eduardo Molteni
I think so, although what you describe, in your 2-tier approach to me, seems like 3-tier, where you just happen to host two of them (font-end and business rules) together. Maybe that isn't 3-tier in the truest sense, but it feels like it to me; all that said, it is exactly how I was thinking of doing it. Because with the seperation as you describe, going to a classic 3-tier would be pretty easy. Thanks!
Nate Bross
It's not 3-tier because they must run in the same process, sure it feel like it.
Eduardo Molteni
I find your description of N-Tier to be contrary to what I've known it as. I've never heard of there needing to be a process/execution boundary between tiers. For instance: an app that maintains 2 assemblies (UI/Domain) + the DB, even if the domain assembly is loaded into the same process as the UI, is still a 3 tier app.
SnOrfus
from Wikipedia: "In software engineering, multi-tier architecture (often referred to as n-tier architecture) is a client-server architecture in which the presentation, the application processing, and the data management are logically separate processes. For example, an application that uses middleware to service data requests between a user and a database employs multi-tier architecture. The most widespread use of "multi-tier architecture" refers to three-tier architecture."
Eduardo Molteni
Better yet: http://stackoverflow.com/questions/312187/what-is-n-tier-architecture
Eduardo Molteni
A: 

In your situation I would go with the simple 2 tier. As long as you separate out the business logic it won't be much work to later host it via WCF (simply tag your interfaces and data objects with ServiceContract and DataContract respectively). This would only be necessary if you have to host your business logic in a separate physical tier from the web tier.

Either way, if you ever go multi-tenant you will probably have to change the architecture in many ways... WCF will be the least of your concerns.

I prefer MVC like the other folks here but I think for a simple app WebForms is fine. Of course if you want to use this as an opportunity to learn MVC, then a simple app may be a good way to start.

DSO
Would it make sense to in this instance, build a Class library that encapsulates all of my business logic and persitance code, and simply reference that in the MVC app? Then, at a later point I could simply host that class library as a WCF?
Nate Bross
Yes. You also have to implement a WCF host process from which your business logic will be exposed, and configure how clients will access it (HTTP, TCP, named pipes... etc). So there is additional work involved using WCF, but your business logic can remain the same.
DSO
One other thing, define your data objects at the business logic layer. If your using LinqToSql, don't expose the Linq generated classes to the clients of your business logic. If you move to WCF it is easier to tag your own data objects with the appropriate WCF attributes to expose it.
DSO
There's no reason to use WCF in your architecture if the only client accessing your business library is your MVC front-end. BTW I prefer MVC for my companies websites but I used WebForms for a quick internal admin site and leveraged a control toolkit. That took less time to develop than MVC and didn't need the advantages that MVC brings to the table vs. WebForms.
Todd Smith
The main reason to use WCF as the "business" tier is to make it easy to swap out front-ends, or add on additional "limited access" modules, that may offer a subset of the features on the main site. Maybe a mobile version that is read-only for example.
Nate Bross