2

There are so many tutorials that teach us to use for example some ORM directly with database, but in real life i cant remember a big project that was working directly with database and not with services, so the amount of that tutorials seems strange to me.
Directly connected applications have real benefits in speed of data transitions between database and the app, and they do not have restrictions in functionality that appear because of service layers(for example lets take Entity framework and WCF Data services(that uses same entity data model itself)). On the other side services solution is more secure and flexible, thats why i(and i think many other programmers) usually choose it for building large applications with some kind of common business logic...BUT! Sometimes lose in speed is up to 10 times! Thats just sad, application becomes less responsive than it could have been.
So the question i want to ask is: can you share your own experience of building enterprise applications without the layer with web/services and when is it a good choice?

Ladislav Mrnka
  • 360,892
  • 59
  • 660
  • 670
0x49D1
  • 8,505
  • 11
  • 76
  • 127

1 Answers1

6

Enterprise application != n-tier application. It means that you can write enterprise application without creating separate physical middle tier (business logic). Creating separate middle tier must always be part of requirements because it is a lot of additional complexity = a lot of additional costs.

Usual requirements for separate middle tier are:

  1. Security - sometimes web server is in DMZ and middle tier must be in secured network
  2. Reusability - you want to use middle tier in more then one application, this also leads to SOA requirement
  3. Scalability - the middle tier can be much more complex so it can be useful to scale it independently on the front end tier. If you want to use middle tier in more then one application you must also be able to scale it independently. Scalability requirement is usually based on performance and availability requirements.

If you don't have any such requirement you can make multilayer application where both front-end and business logic sits in the same process on the same server.

Ladislav Mrnka
  • 360,892
  • 59
  • 660
  • 670
  • 1
    Very nice answer. I usually dont want same business layer across several applications. But security..Here is a problem. Clients usually have closed server with database and client computers must be in VPN to reach it directly. And with services we can put just one server into VPN and reach it with client computers over "open" web. Security always has impact on speed. Eh..And clients want more responsiveness! Ok..ill try to ask for reasonable conditions for such solutions(like good channel between service server and DB one and good service server to work with all clients) – 0x49D1 Apr 10 '11 at 10:42
  • But isnt this a good solution: to protect yourself from clients changes and future requirements-build n-tier application(sure take bit more time)? Almost always clients want to continue some projects and add some features-that can lead to change 2 tier to 3 or more..Seems that flexibility is ALMOST always a good idea. – 0x49D1 Apr 10 '11 at 10:47
  • 1
    @nihi: It depends on your development approach and real world experience with your client. Flexibility is a good idea but in the same time you should not develop something that client don't want at the moment (agile school) because in the same time you can find later on that it was waste because no further changes require 3-tier application. – Ladislav Mrnka Apr 10 '11 at 10:54