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!

  • People still talk in terms of "DAL"s and "BLL"s? Party like it's 1999... – Aaronaught Sep 12 '13 at 1:58
  • how does people talk today then? – Sisyphus Sep 12 '13 at 14:47
  • They're just obsolete concepts. There are any number of more modern design methodologies (BDD, DDD, TDD, etc.) and architecture styles (SOA, ROA, OOA, etc.) almost all combinations of which acknowledge that strictly separating "data" and "business" is selling yourself short. – Aaronaught Sep 13 '13 at 0:09
  • Do you have a specific reason other than the fact that desktop app uses only 20% of the layers? If not then you should not duplicate the code. You can think is to create a layer in your DAL/BAL. e.g. ICommon <- IWeb. – user1278577 Mar 11 '14 at 6:59

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.

  • i am not concerned about the size, i am just concerned about distribution of my code, nowadays with the existance of reflectors and everthing it is always best to keep your code files distributed at the bare minimum. unfortunately webservices is not an option because many times the desktop application will work in a disconnected enviroment so it will have to operate independtly for periods of time. – Sisyphus Sep 12 '13 at 2:04
  • Is your business and data access logic so unique as to warrant the extra work? Even if so, it should be possible to include only the modules or packages that the desktop app requires at build time. – Mike Partridge Sep 12 '13 at 2:08
  • that solution would be good, how could i achieve this? – Sisyphus Sep 12 '13 at 7:29
  • How to achieve it depends on entirely on your build system. – Mike Partridge Sep 12 '13 at 12:13
  • i am using visual studio.net c#, DAL and BLL are both built in independent class libraries. – Sisyphus Sep 12 '13 at 14:48

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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