473,378 Members | 1,492 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Sharing code across projects

I'm working with a group that's been doing C++ coding for quite a long
time, now, and in that environment we've pretty much worked out
development practices that serve us well.

We've been doing more and more, over the last few years, in C# and
ASP.NET. Some web apps, some background services.

In our C++ code base, we have a fair number of statically-linked
libraries that contain code we share between projects. At this point, in
our C# code, we have only separate files in each project containing
similar code.

We would like to move those separate files containing similar code in
each project to single files shared between projects, the way we have
been doing with our statically-linked libraries. We just haven't quite
figured out what is the best way of doing it.

What would seem most obvious is simply to create DLL projects for each of
our shared class collections, and to reference the DLLs in the main
projects. The problem is that the main projects have different release
schedules. Each would have to ship with different versions of the shared
DLLs. That means, of course, that we'd need to create a tag in version
control on every shared DLL for every release. No big deal. We'd have
to do the same with statically-linked libs.

But to complicate things, we have some customers who have multiple
projects installed. And that means that we will have customer machines
with different versions of the shared DLLs installed for different
projects. And that's when our support staff starts to scream.

Is there a way of sharing code between projects so that it ends up in a
single assembly, instead of requiring separate DLLs? Someone recommended
using the "Add as Link" option of "Add Existing Item", but I'm not sure
that really addresses the problem I'm talking about, and it doesn't seem
to work in Web Apps anyway, and we need a solution that works in both.

(You can assume that we will have some classes that will be shared across
all web apps, some classes that will be shared across all non-web apps,
and some classes that will be shared across all apps, web and non-web
both.)

Any ideas?

What should I be looking at?

--
Freedom is not empowerment. Empowerment is what the Serbs have in
Bosnia. Anybody can grab a gun and be empowered. It's not entitlement. An
entitlement is what people on welfare get, and how free are they? It's
not an endlessly expanding list of rights - the 'right' to education,
the 'right' to health care, the 'right' to food and housing. That's not
freedom, that's dependency. Those aren't rights, those are the rations
of slavery - hay and a barn for human cattle.
-- P.J. O'Rourke
Jun 27 '08 #1
2 1950
"Jeff Dege" <jd***@jdege.visi.comwrote in message
news:n6******************************@posted.visi. ..
What should I be looking at?
Any source control software will do this:
http://msdn.microsoft.com/en-us/vs2005/aa718670.aspx
http://msdn.microsoft.com/en-us/team.../aa718934.aspx
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Jun 27 '08 #2
On Wed, 14 May 2008 22:24:08 +0100, Mark Rae [MVP] wrote:
"Jeff Dege" <jd***@jdege.visi.comwrote in message
news:n6******************************@posted.visi. ..
>What should I be looking at?

Any source control software will do this:
http://msdn.microsoft.com/en-us/vs2005/aa718670.aspx
http://msdn.microsoft.com/en-us/team.../aa718934.aspx
We've thought about that, but we're not certain how to handle merging of
release branches.

Suppose project A depends on library C. When we're ready to ship version
3.1 of project A, we create a A_3_1 branch on library C. After A ships,
we continue development on other projects, and library C continues to
change.

Now suppose we have to go back and make changes to project A, and some of
those changes will need to be made in the library C code. We have two
choices - we either move the version of library C that is used in project
A forward to the most current version, and then make any changes that
need to be done for project A, or we make our changes on the A_3_1 branch.

Most of the time we will do the former. But we need the ability to do
the latter. And when we do need to do the latter, we also need the
ability to merge the changes we made on the A_3_1 branch into the main
stream of development.

This kind of thing is confusing enough to keep straight when you have
named releases, and an independent release history, for your shared
library. Trying to keep it straight absent that is almost certainly an
exercise in futility.

From Robert Martin:

http://www.objectmentor.com/resource...ranularity.pdf

The Reuse/Release Equivalence Principle (REP).

THE GRANULE OF REUSE IS THE GRANULE OF RELEASE. ONLY COMPONENTS THAT ARE
RELEASED THROUGH A TRACKING SYSTEM CAN BE EFFECTIVELY REUSED. THIS
GRANULE IS THE PACKAGE.

Reusability is one of the most oft claimed goals of OOD. But what is
reuse? Is it reuse if I snatch a bunch of code from one program and
textually insert it into another? It is reuse if I steal a module from
someone else and link it into my own libraries? I dont think so.

The above are examples of code copying; and it comes with a serious
disadvantage: you own the code you copy! If it doesnt work in your
environment, you have to change it. If there are bugs in the code, you
have to fix them. If the original author finds some bugs in the code and
fixes them, you have to find this out, and you have to figure out how to
make the changes in your own copy. Eventually the code you copied
diverges so much from the original that it can hardly be recognized. The
code is yours. While code copying can make it easier to do some initial
development; it does not help very much with the most expensive phase of
the software lifecycle, maintenance.

I prefer to define reuse as follows. I reuse code if, and only if, I never
need to look at the source code (other than the public portions of header
files). I need only link with static libraries or include dynamic
libraries. Whenever these libraries are fixed or enhanced, I receive a
new version which I can then integrate into my system when opportunity
allows. That is, I expect the code I am reusing to be treated like a
product. It is not maintained by me. It is not distributed by me. I am
the customer, and the author, or some other entity, is responsible for
maintaining it.

When the libraries that I am reusing are changed by the author, I need to
be notified. Moreover, I may decide to use the old version of the library
for a time. Such a decision will be based upon whether the changes made
are important to me, and when I can fit the integration into my schedule.
Therefore, I will need the author to make regular releases of the
library. I will also need the author to be able to identify these
releases with release numbers or names of some sort.

Thus, I can reuse nothing that is not also released. Moreover, when I
reuse something in a released library, I am in effect a client of the
entire library. Whether the changes affect me or not, I will have to
integrate with each new version of the library when it comes out, so that
I can take advantage of later enhancements and fixes.

And so, the REP states that the granule of reuse can be no smaller than
the granule of release. Anything that we reuse must also be released.
Clearly, packages are a candidate for a releasable entity. It might be
possible to release and track classes, but there are so many classes in a
typical application that this would almost certainly overwhelm the
release tracking system. We need some larger scale entity to act as the
granule of release; and the package seems to fit this need rather well.
--
It is not from the benevolence of the butcher, the brewer, or the baker
that we expect our supper, but from their regard to their own interest.
- Adam Smith, "The Wealth of Nations"
Jun 27 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Simon Neve | last post by:
Hello, This question is related to sharing .Net projects across solutions and is reposted from the SourceSafe group. We have several different solutions and want to share common assemblies...
5
by: cybertof | last post by:
Hi ! What is the common use of sharing a single .cs across multiple project files ? I think it's to share common classes between projects. I have actually a .cs file shared accross multiple...
5
by: geoffblanduk_nospam | last post by:
Is it valid to share namespaces across projects in C#? For example, I have a project that contains the code for a core assembly, this builds a DLL. I then have a second project in the same...
0
by: Daniel | last post by:
Hi! I have several projects (approx 50) that includes basically the same files such as <atlcom.h> and <comdef.h>. The projects are set up to use a precompiled header wich includes these header...
0
by: Darren Oakey | last post by:
G'day - is there anyway of sharing the Session data across two different ASP.Net projects? Basically, I'm jumping from a page in one to a page in another, and I'd like to have the data flit...
3
by: Shikari Shambu | last post by:
Hi All, I have a situation where multiple applications are sharing some pages/ controls. So, I have a separate common project that has the common pages/ controls. My question is how do I...
0
by: rcolby | last post by:
Hi, A little advice on code sharing across projects, namespaces and dll's for references. I've got an application that is split between three different projects (one for a service, one for...
2
by: David | last post by:
How do I share code across files in C#, without including a reference to a class library. Here's what I want to do. I have a device I want to talk to. It's a machine in a factory. It can talk...
1
by: Matt Owens | last post by:
Hi, Im setting up a new project in which I'd like to share code across numerous other projects, specifically a control library and an array of common objects. Im not really sure how best to go...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.