Pergunta

I've worked on a project that implements a three-tier architecture with the following design:

  1. Presentation Layer - Uses PHP with an MVC framework to handle frontend presentation and business logic. This layer makes calls to the service layer, which accesses the data.
  2. Data Access Layer - Uses C# .NET and is separated into Service, Business Logic, and Data Layer. Called by the Presentation Layer. Makes calls to the database and serializes responses to return to the Presentation Layer.
  3. Data Layer - The database. Provides all of the data for the above two layers.

I understand that a three-tier approach can help security, since there is still no access to the data if the Presentation Layer is compromised. Although this is true, it seems like this approach is over-complicating it a bit, especially since I'm forced to write two models for the same object in the first two layers.

So my question: Is this a bad implementation of a three-tier architecture? If so, how could it be improved? What are the drawbacks, if any, of simply having an MVC implementation that has access to the database? What approache(s) do you use for your web applications?

Thanks for the help!

Foi útil?

Solução

It looks to me like your 3 tiers are the same as View, Controller Model. If your php is mainly making calls to your #2 layer, then I would think itself doesn't need to be MVC unless you have a very complicated presentation layer that itself should be organized into MVC, for instance if you have complicated navigation or user authentication logic.

Outras dicas

There is nothing necessary in programming. But there are a bunch of practices, that were prooven by years as something-you-can-follow-to-get-better-results. N-tier separation is just one of that practices.

http://en.wikipedia.org/wiki/Multitier_architecture

Your description follows the description in the wiki, so - it is suitable way to implement 3-tier app.

But remember, you don't ought to do anything - just follow the way it is comfortable for you. And in future you'll have your own set of practices that work for you specifically.

I think your complication stems from the fact that you're using PHP and .NET, which aren't directly compatible. If you eliminated one of those (only used PHP or only used .NET) that would simplify things. Otherwise, I think you're using a good approach.

The value of the approach is not just for security, it also facilitates maintainability.

I am not sure I understand the concern: "especially since I'm forced to write two models for the same object in the first two layers." This would seem to be because you are using two different programming languages for the UI and the back-end. I'm guessing C# "data access layer" contains a complete object model which you then have to replicate in your front end.

The problem seems to be that you have two middle tiers that mirror each other, because you're using two languages, not that you are using a n-tier architecture

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top