1

I read the StackOverflow guidelines and looked for a design-specific SE site. If you feel this question is still too long or unclear, please let me know and I'll try again.

I maintain an N-tier line of business, winforms application with the following layer/design:

  • [WinForm Application]
  • [MVP-based Presentation Layer (CAB, specifically)]
  • [Service Layer]
  • [Data Access Layer]

The application integrates with different ERP/business systems which is handled at the DAO layer by use of ERP/business system specific implementations of DAO interfaces, for example:

public sealed class QBTransactionAssemblyBuildDAO : QBDAO, ITransactionAssemblyBuildDAO
public sealed class SAPTransactionAssemblyBuildDAO : SAPDABase, ITransactionAssemblyBuildDAO

For example, one business division may use the application integrated with QuickBooks. This will be configured in the app.config and a factory method will create the appropriate QB*DAO implementations at runtime. Likewise another division may use it integrated with SAP, the config file will support this and the factory will produce SAP*DAO implementations. The services can then use the DAOs while remaining ignorant of the underlying integrated system.

This all worked great and in fact the design has paid dividends as I've had to add additional integrated systems and record support. That all changed today when I ran into a situation where an integrated application's API did not support a task that all the other systems can support. I'm now in a situation where I need to support an exceptional flow and rather than update data in say, SAP I need to present a dialog to the user with the data for them to manually transcribe (OK, copy and paste) into the SAP application user interface.

If I adhere to my layer and object separation guidelines the first opportunity for me to branch my application flow is at the service layer as this layer is knowledgeable about which ERP/business applications are integrated. At the service layer I can receive the request to "RecognizeDelayedRevenue", get my reference to my concrete DAO object and ask it if it supports the operation (the latter part being new). If it returns negative I now have the design challenge of presenting a dialog to the user, including pre-processing the data it presents using methods that belong on the DAO objects.

My question: From a design standpoint, which is the bigger sin:

  1. Service layer attempts to create and show win32 dialogs, basically breaking the separate of business logic and presentation
  2. The DAO object accepts (i.e. claims to suport) the request and rather than executing against it's integrated system, it somehow presents a dialog to the user
  3. Bring integrated system knowledge down to the presenter level and handle the exception there.

Of course if you have an idea that I haven't mentioned, that would be very interesting as well! :)

1 Answer 1

1

I'd go with #3 but I'd use a role interface to maintain a level of abstraction. I'd then have my presentation layer query for the presence of that interface when it must decide whether to use the additional feature:

if (myImpl is IAdditionalFeatureAware)
{
    // ...
}
2
  • I'm a fan of Fowler but Role Interface has not caught my attention before; thanks for the link. I'm struggling with how to apply your suggestion to my 3 participating layers: The object that would (or would not) implement the Role Interface would be my DAO object which is unknown to the presentation layer. How would you involve the service layer in this solution? My service purports to handle the task that is the subject of this question, but it isn't until IT tries to use the DAO layer that it can inspect for Role Interface. I hope that made sense.
    – scubasteve
    Nov 13, 2016 at 4:01
  • Ah. Yes. I missed that detail. This makes it more complicated as the service might support the ability to query an interface while it's used as a native part of the stack, but if it becomes, or is, a remote interface, you'll need to look at asking the service if it supports that functionality, obtaining the answer as part of a response. You might be able to do this once and hold on to the answer rather than constantly querying? Nov 14, 2016 at 8:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.