views:

58

answers:

2

I've a project where some business logic is separated to an DLL project, this DLL contains the business logic for this software for a specific customer.

Now I've a problem after another client with different rules want to implement the software, I need someway that the application load the appropriate dll according to the client using the software, considering that this dll contains same function names but different bodies.

I'm using c# 3.5, is there a way to do so ??

+5  A: 

Yes, you certainly can. You can branch the project, alter the implementation of the classes, keep the signatures of all the classes and class members the same, recompile, and your business logic will behave as you wish.

But, this is not good. You will have two different branches, with different implementations, for which you will have to keep the signatures in synch forever. And then you'll have another client, and another. This will be a nightmare that never ends.

Is is possible that the differing functionality can be separated out? You can:

  • put configuration in the database or configuration files (probably XML). A lot of your app should work based on tables or config files, for this reason.
  • you can implement plug-ins and providers for places where the code needs to be different.
  • kindof oldschool, but you can implement plug-and-play functionality using the part of CodeDom that compiles code (ignore the part about graphing out code). You can then put functionality in easily edited text files.
  • take a look at the Managed Extensibility Framework, built for just this type of thing.
Patrick Karcher
So what's your recommended solution?
Robert Harvey
@Robert: Just put in some options. Setting up software to work for different clients is tricky, especially that 2nd client. The problem is some salesman or boss figured it would be easy to "just tweak it a bit", now Mustafa has to make it work.
Patrick Karcher
+1 for options, and MEF. MEF is cool.
Robert Harvey
+1 for MEF. It takes a little gymnastics to get your head arond it, but it handles dynamic loading of client-appropriate code very well.
dthorpe
A: 

Code the business Logic against an Interface - IBusinessLogic.

You can keep both business logics in the same assembly, and use config based dependency injection to specify which business logic is used during the deployment to the customer.

Tom Anderson