On Wed, 2010-09-08, Ángel José Riesgo wrote:
> On Sep 7, 7:45*pm, Jorgen Grahn <grahn+n...@snipabacken.se> wrote:
>> On Mon, 2010-09-06, Ángel José Riesgo wrote:
>> > On Sep 6, 9:30*am, thomas <freshtho...@gmail.com> wrote:
>> > [...] In order to use these utilities
>> > from the projects A and B, you would need to add the "util/include"
>> > path to the search paths for #included files and make those projects
>> > link against "utils/include/util.lib".
>>
>> You mean "utils/bin/util.lib" here.
>
> Sure. Sorry about the typo.
>
>> I very much prefer flat structures. I don't see any rational reason
>> for the very fine-grained directory structures I encounter all the time.
>>
>> In this case, I'd have utils/util.cc and utils/util.h, and user code
>> would #include <utils/util.h>. Requiring callers to add utils or
>> utils/include/ to the include search path doesn't scale, and
>> complicates the Makefile more than you'd think.
>
> There are several factors involved, and there is no perfect solution,
> but what I like about having two separate "include" and "source"
> directories is that there is then a clear distinction between the
> source code that is needed for the client users of the Util library
> and the source code that is required for building the library.
I understand that point of view; I just don't think it's worth the
effort, given the negative effects of doing so. Remember that this
something /you/ both create and use; it isn't a third-party library.
>> >> option2: I can put a Util.cpp in A and B.
>> >> * *--> obviously bad because I need to change Util.cpp in every
>> >> projects if necessary.
>>
>> > I agree. This would be a nightmare in terms of maintenance.
>>
>> That seems to be a common reaction to the idea, but I cannot see a
>> rational reason for that either. Exactly /what/ is nightmarish about
>> it? *Remember, we're talking general utility functions here, stuff we
>> cannot even be bothered to name properly. (Yes, I use the name in my
>> own code, too.)
>
> I suppose it depends on the size and extent of use of such utilities,
> but if you end up using them in many places, it may be difficult to
> keep them in sync when fixing errors, etc.
That's a much better description, and I kind of agree. But my gut
feeling is that you're more likely to have foo/util and bar/util
diverge over time as they are adapted to the specific needs of 'foo'
and 'bar'.
The "difficulty" is also mostly a matter of "if you fix a bug here,
try to remember to apply the same patch there". That's something you
already do to other things. For example, if you discover a better way
of handling command-line options, you probably apply this better way
to all your software sooner or later, even though separate programs
have separate command-line parsers (separate getopt(3) loops in Unix).
/Jorgen
--
// Jorgen Grahn <grahn@ Oo o. . .
\X/ snipabacken.se> O o .
|