How should communication between n-tier levels between tiers be made?

I recently discussed the best way to handle chain communication in an n-tier architecture.

Currently, the methods I'm doing are throwing and handling exceptions between levels for errors and using events / delegates for other communication (for updating progress indicators, etc.). Are they the best way or is there another method that I overlooked that would be considered best practice?

+4
source share
3 answers

Exceptions are indeed a good way to handle errors from lower levels.

In my opinion, delegates are most useful when one object to which another object belongs must configure this object. This may make sense if your levels logically "own" objects at lower levels - otherwise I will probably shy away from the delegate pattern and use events.

+1
source

I would say that you are on the right track, since exception handling is the implementation of a chain of responsibility chains. It's always good to throw an exception in the chain. As for the other (events / delegates), I did not quite understand your expression, so I could not comment on this.

+1
source

I tried using an adapter template. The main objects lie in the logical layer and are wrapped using composite objects so that presentation and data access layers can work. Most classes of presentation and data access classes use interfaces. Wrapping (compound) objects lie in the layers of presentation and access to data and implement the interfaces of these layers.

In addition to composite objects, there are controller objects that can extract data from logical objects and create new objects (i.e. a list of rows).

+1
source

All Articles