Domanda

I'm currently building a very small website, around 20 to 30 views, 10 controllers.

I know MVC is only a design pattern and should only be the top presentation layer. I'm currently at a stage in development when you start question yourself and what you're doing. It feels like this small website don't 'need' the N-tier architecture because it's too small for that. But in the long run maybe it's worth it.

Is it worth the time to migrate to N-Tier?

IS there some level of abstraction when you should migrate to n-tier? Is there some magic point when the project grows too large? Or should it be done directly in the beginning of the development?

È stato utile?

Soluzione

Well, let's evaluate what you are asking first.

Your application is currently a Model-View-Controller application. What does that mean? It means your application has:

  • A Presentation layer, the View,
  • An Application Processing Layer, the Controller, and
  • A Data Management Layer, the Model.

What would it take to convert it to N-tier? Well, according to Wikipedia, a Multi-Tier application is

a client–server architecture in which presentation, application processing, and data management functions are physically separated.

Hmm, seems like you have multi-tier already.

If you don't buy that, then make your Data Layer a web service. That way your MVC application will be able to access it, and so will your mobile application, your desktop application, or any other application that you wish to write.

In any event, multi-tier is primarily about scaling applications to multiple machines. Writing web services accomplishes that in part, but so does splitting parts of your application to multiple machines on the same intranet. Whether or not you need all this depends entirely on your application and its scope.

Altri suggerimenti

Let's look at some questions I ask when I am building a website:

  • Do you expect your website to grow in either views or complexity?
  • Do you expect there to be more "pages" in the future?
  • Do you know that you will need a data provider on the back end at some point in the future, even if not currently?
  • Will you have other developers working on this site, possibly at the same time as you?

If you can answer yes to all (or most) of the above questions, then it is worth the time and effort to build out the n-tier framework. If you will have multiple developers working on it at the same time, that would almost guarantee (at least to me), that the additional effort will be worth it.

If you can't, then it may not be worth the effort.

Yes, you should. MVC is a presentation layer pattern. One day you might want to add other presentation layers such as a WPF one or some mobile one. 3-tier will enable you to do that while reusing the business logic layer and the data access layer.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
scroll top