Is this a viable design idea?

  • Thread starter Thread starter Tosch
  • Start date Start date
T

Tosch

I have an order processing application with many features.
I want to be able to put some features in external and configureable
DLLs.
The main application has to pass an order object (and possibly some
other objects) to the external dll.

I have designed a base class with just interfaces on which the real
dlls base. The main application has a reference to this base class.
The external dlls (and the base class) need a reference to the main
application so it can properly use the classes that are passed from
the main application to the external dlls.

Since the main app has a reference to the external dlls and the
external dlls have a reference to the main app this looks to me like
circular reference.

Can I get into trouble with this design? Is it better to move all the
classes to a separate dll and reference this dll from the main
application and the external dll?

Any comments welcome

Tosch
 
It would be a circular reference.

Assuming the following assumptions are correct then the subsequent
suggestion could be of use to you:
1) You are using the Base class as a means to expose a limited interface to
your main application.
2) Your Order object is used BY your external dll, and your Order object
does not need a reference to
your external DLL.

Suggestion:
1) Take your Order Objects out of the Main App and put them in Order.dll
2) Add Reference to Order.dll in Main App
3) Add Reference to Order.dll in your existing 'external' dll

= No Circular References.

Also if the Base Class is just an interface then consider creating an
Interface and using Implements in your
external DLL Classes.

Hope this helps some
Neil
 
Neil,
thanks for your comments.
The base class is indeed just an interface and the 'real' external
DLLs implement that interface.
The way I have designed it now (with circular reference), it does
acutally work, except for a warning when compiling. But it just
doesn't feel right.
I will put the order object and any objects that I pass between the
main application and the external DLLs in a separate DLL, just seams
cleaner to me too.

Tosch
 
Tosch,

FYI, your app will work fine with circular references ... for a while. With
circular references (A>refs>B>refs>A) even after your app appears to have
closed down, the objects will remain alive in memory (that cannot be
accessed again) until you restart your machine.

This is a memory leak.

Therefore, if you use your app multiple times without restarting you'll
eventually use up all your memory.

Try adding some Logging code to your Class_Finalize method and you'll see
the difference between closing your app with circular references and closing
your app with non-circular references.

Cheers,

Neil
 
Back
Top