How to split a project in many DLL projects

  • Thread starter ABC - Sébastien Beaugrand
  • Start date
A

ABC - Sébastien Beaugrand

Hi,

I am working on a project that is getting too big and we would like to split
it in many DLLs Projects.
In that way some dlls should be written in C# and some in VB.NET.

The problem we got to do that is that if we cut a part of code from the main
project (Project1) and if we put it in a new DLL project (Project2) it is
not possible to compile Project2 because it need to declare some classes
that are defined in Project1.

To resolve that problem, in project 2 we add a reference to Project1.

But now, because some functions called by Project1 have been moved to
project2, we need to add a reference to project2 in the main project
(project1).

And we got circular references and it is impossible to build the solution
!!!

So what is the correct way to organize an oo project in many DLLs ?

Thanks
Sebastien
 
J

Jay B. Harlow [MVP - Outlook]

Sebastien,
And we got circular references and it is impossible to build the solution
!!!
The normal way to avoid circular references between assemblies that require
a circular reference is the Separated Interface Pattern.

http://www.martinfowler.com/eaaCatalog/separatedInterface.html

However this is not always as easy as it appears.
The problem we got to do that is that if we cut a part of code from the main
project (Project1) and if we put it in a new DLL project (Project2) it is
not possible to compile Project2 because it need to declare some classes
that are defined in Project1.
Normally what I do is move the code that both Project1 & Project2 depend on
into Project3.

Then Project1 references both Project2 & Project3, while Project2 references
only Project3.

Normally I call this Project3 MySolution.Framework. What I wind up with is
very little code in Project1 as most of it is in Project2 type assemblies
with all the common stuff in Project3 type assemblies.

If you do not start out organizing you classes into projects from the start,
it can be challenging as you are finding to get classes that have no
dependencies into their own assemblies, I know I've been there.

Hope this helps
Jay
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top