S
Scott Roberts
We're just getting started on our new .NET project. When I started, I was
just throwing everything into one DLL (assembly) and there were few
problems. I then decided that multiple assemblies would be a good idea for
several (rather typical, I believe) reasons including versioning, security,
deployment options, and general code organization. The model I have come up
with is as follows:
GUI assemblies (windows forms, asp.net, etc.)
Application assemblies (non-visual classes specific to a particular
"application"). Our customers may purchase any combination of applications.
We only deploy the one(s) they purchase.
Framework assembly. There is only one framework assembly. It contains base
classes that most (all?) of the classes in the application assemblies are
derived from. Most importantly, it implements functionality for persisting
objects to a database.
Database assemblies. There would conceivably be an assembly for each
database we support (there is only one assembly for SQL Server at this
time).
I think this is a fairly typical design. I can deploy one framework DLL
along with whatever application, GUI, and database DLLs are appropriate for
a particular customer. Sounds peachy.
However, there is a problem.
The "database" assemblies and the "application" assemblies both access the
"framework" assembly, but they need very different types of access. Namely,
the "database" assemblies need to be able to read private data of the
classes defined in the framework assembly in order to persist them into the
database. So, some properties (or classes) in the framework DLL should be
visible to the database DLLs, but not to the application DLLs.
I read up on the "friend" functionality ("internal" in c-sharp), but if I
understand correctly it requires that "friend" classes be in the same
assembly. I like the idea of having the database assemblies seperate so that
I can:
1. Deploy only the database DLLs necessary for a particular customer. Why
include code for accessing an Oracle database to a customer that is using
SQL Server?
2. I can write a new assembly to access a new database without touching the
framework assembly. If we get a new customer that wants to use MySQL, I can
just write an assembly for MySQL and deploy the rest of the application as
usual.
So, what to do? Allow public access to all properties on the framework
classes so that the database assembly can read them? Roll the database
access classes into the framework assembly? Are there some other features
that I've missed? I haven't looked into reflection all that much, but it
seems overly complicated for my simple plan. And, I would assume that the
same "public/friend" access permissions exist for reflection that they do
for "normal" coding practice.
I guess what I would really like is to make two assemblies "friends", so
that they work closely together but can be deployed seperately.
Any insights, links, corrections, comments, or questions are welcome.
just throwing everything into one DLL (assembly) and there were few
problems. I then decided that multiple assemblies would be a good idea for
several (rather typical, I believe) reasons including versioning, security,
deployment options, and general code organization. The model I have come up
with is as follows:
GUI assemblies (windows forms, asp.net, etc.)
Application assemblies (non-visual classes specific to a particular
"application"). Our customers may purchase any combination of applications.
We only deploy the one(s) they purchase.
Framework assembly. There is only one framework assembly. It contains base
classes that most (all?) of the classes in the application assemblies are
derived from. Most importantly, it implements functionality for persisting
objects to a database.
Database assemblies. There would conceivably be an assembly for each
database we support (there is only one assembly for SQL Server at this
time).
I think this is a fairly typical design. I can deploy one framework DLL
along with whatever application, GUI, and database DLLs are appropriate for
a particular customer. Sounds peachy.
However, there is a problem.
The "database" assemblies and the "application" assemblies both access the
"framework" assembly, but they need very different types of access. Namely,
the "database" assemblies need to be able to read private data of the
classes defined in the framework assembly in order to persist them into the
database. So, some properties (or classes) in the framework DLL should be
visible to the database DLLs, but not to the application DLLs.
I read up on the "friend" functionality ("internal" in c-sharp), but if I
understand correctly it requires that "friend" classes be in the same
assembly. I like the idea of having the database assemblies seperate so that
I can:
1. Deploy only the database DLLs necessary for a particular customer. Why
include code for accessing an Oracle database to a customer that is using
SQL Server?
2. I can write a new assembly to access a new database without touching the
framework assembly. If we get a new customer that wants to use MySQL, I can
just write an assembly for MySQL and deploy the rest of the application as
usual.
So, what to do? Allow public access to all properties on the framework
classes so that the database assembly can read them? Roll the database
access classes into the framework assembly? Are there some other features
that I've missed? I haven't looked into reflection all that much, but it
seems overly complicated for my simple plan. And, I would assume that the
same "public/friend" access permissions exist for reflection that they do
for "normal" coding practice.
I guess what I would really like is to make two assemblies "friends", so
that they work closely together but can be deployed seperately.
Any insights, links, corrections, comments, or questions are welcome.