I am working on a project that has two interface (web and desktop), they are not performing the same tasks but they use the same BLL and DAL, the web part using 100% of the BLL and DAL, while the desktop only needs to know about 20% of the BLL and DAL.
Do you think it is a good idea to let the desktop use the same BLL and DAL as the web, which consequently will lead to distributing thos BLL and DAL with the desktop application? Or you think I’d better create new BLL and DAL projects just to serve the desktop app? But in this case I will fall in the trap of maintaining two copies of the same code!
4
You haven’t provided any specifics as to why you’re concerned about distributing the extra code with your desktop app, but in general, keeping code duplication to a minimum should be a high priority.
My best guess is that you’re concerned about the size of your desktop app when it includes the code that it doesn’t use, but unless it pushes the size beyond 20MB or so to be downloaded over the internet, I wouldn’t be too worried about it.
If you do have good reasons to believe that the size with unused code will be prohibitive, the first thing I would do is look into ways that I could include in the desktop package only those modules of the BLL and DAL that it needs. In Java I would try to break monolithic packages into smaller ones, and modify the build script to jar up only those packages that it uses.
Another option would be to make web service calls to your webapp from the desktop app, which can make sense in situations where you expect to eventually support many different apps, e.g. desktop, iOS, Android, etc, but it’s not trivial undertaking.
6
I am not sure if this would be an answer to everybody, but it solved the issue for me.
I used the same DLL and BAL layers for the two GUIs, then used an assembly pruner application to prune the classes that were not used by the desktop application out of the DAL and BLL assemblies.
Example of these pruning application is RegGate SmartAssembly that offers the pruning feature among many other features.
Perhaps your problem its that you have only one model, big applications are normally composed or various decoupled models, in Domain Driven Design this concept is called Bounded Context.
In a system designed like that your desktop application probably use several of this BC’s and your web application use all, this way you can distribute the desktop app with only the needed BC’s.
Off course duplication its the worse you can do, better think in ways of modularize your model and distribute only the modules (BC’s) you really need in each case, but its much better your current situation than the situation of having 20% of your code duplicated.