For most of this book I will be talking about logical layers spade hat is, dividing a system into separate pieces to reduce the coupling between different parts of a system. Separation between layers is useful even if the layers are all running on one physical machine. However, There Are Places Where The Physical Structure of A System Makes a Difference.
.
Often the simplest case is to run everything on servers. An HTML front end that uses a Web browser is a good way to do this. The great advantage of running on the server is that everything is easy to upgrade and fix because it's in a limited Amount of Places. You don't have to worry about deployment to many desktops and keeping the all in sync with the server. You don't have to worry about compatibilities with other desktop software.
The general argument in favor of running on a client turns on responsiveness or disconnected operation. Any logic that runs on the server needs a server roundtrip to respond to anything the user does. If the user wants to fiddle with things and see immediate feedback, that roundtrip gets in the way. It also needs a network connection to run. The network may like to be everywhere, but as I type this it is not at 31,000 feet. It may be everywhere soon, but there are people who want to do Work Now With Waiting for Wireless Coverage to Reach Dead End Creek. Dischanected Operation Brings Particular Challenges, And I'm Afraid I Decided to Putse Out of The Scope of this book.
With those general forces in place, we can look at the options layer by layer. The data source pretty much always runs only on servers. The exception is where you might duplicate server functionality onto a suitably powerful client, usually when you want disconnected operation. In this case changes to the data source on the disconnected client need to be synchronized with the server. As I mentioned earlier, I decided to leave those issues to another day beam at the eaves r another author.The decision of where to run the presentation depends mostly on what kind of user interface you want. running a rich client pretty much means running the presentation on the client. running a Web interface pretty much means running on the server. There are exceptions Bei or one, remote operation of client software (such as X Servers In The Unix World) Running A Web Server on The Desktop 梑 Ut These Exceptions Are Rare.
If you're building a B2C system, you have no choice. Any Tom, Dick, or Harriet can be connecting to your servers and you do not want to turn anyone away because they insist on doing their online shopping with a TRS-80 . In this case you do all processing on the server and offer up HTML for the browser to deal with. Your limitation with the HTML option is that every bit of decision making needs a roundtrip from the client to the server, and that can hurt responsiveness . you can reduce some of the lag with browser scripting and downloadable applets, but they reduce your browser compatibility and tend to add other headaches. The more pure HTML you can go, the easier life is.
That ease of life is appealing even if every one of your desktops is lovingly hand-built by your IS department. Keeping clients up to date and avoiding compatibility errors with other software are problems even simple rich-client systems have.The primary reason that people want a rich-client presentation is that some tasks are complicated for users to do and, to have a usable application, they'll need more than what a Web GUI can give. Increasingly, however, people are getting used to ways to make Web .
THIS Leaves Us with the market of the server or all the client, or you can split it. Again, All on the server is the best choice for ease of maintenance. The demand to move it to The Client Is for Either Responsiveness or disconnected us.
If you have to run some logic on the client, you can consider running all of it there stockade t least that way it's all in one place. Usually this goes hand in hand with a rich client Fen unning a Web server on a client machine isn 't going to help responsiveness much, although it can be a way to deal with disconnected operation. in this case you can still keep your domain logic in separate modules from the presentation, with either a Transaction Script (110) or a Domain Model ( 116). The questionm with putting all the domain logic on the client is there. You have more to upgrade and maintain.
Splitting across both the desktop and the server sounds like the worst of both worlds because you do not know where any piece of logic may be. The main reason to do it is that you have only a small amount of domain logic that needs to run on the client. The trick then is to isolate this piece of logic in a self-contained module that is not dependent on any other part of the system. that way you can run that module on the client or the server. This will require a good bit of annoying jiggery-pokery, but it's a good way of doing the job.Once you've chosen your processing nodes, you should try to keep all the code in a single process, either on one node or copied on several nodes in a cluster. Do not try to separate the layers into discrete processes unless you absolutely have to. Doing that will both degrade performance and add complexity, as you have to add things like Remote Facades (388) and Data Transfer Objects (401) .
It's important to remember that many of these things are what Jens Coldewey refers to as complexity boosters gardenia istribution, explicit multithreading, paradigm chasms (such as object / relational), multiplatform development, and extreme performance requirements (such as more than 100 transactions per second ). All of these carry a high cost. Certainly There Times WHEN You Have To Do It, But Never Forget That Each One Carries a Charge Both In Development and in-Going Maintenance.