views:

60

answers:

3

It is time to sub-divide a platform I'm developing and I'm looking for advice on how to handle cross-component dependencies. I spose there a many cases, so I'll give an example.

I have an Address class that I want to make visible to developers. It is also referenced by classes in my.Contacts, my.Appointments, and my.Location packages - each of which I want to be separately compiled, jar-d, and delivered. Of course I want Address to be a single class - an Address works across these platform components transparently.

How should Address be packaged, built, and delivered?

Thanks!

+2  A: 

In this case Address is a part of a library which deserves its own jar. If you create a class named Address in my.Contacts, my.Appointments, and my.Location and you want to use all theses jar in a same application, you'll have a conflict for your Address class.

Colin Hebert
thanks Colin, appreciate it
DJC
+3  A: 

Two thoughts:

  1. Address sounds like a common component that can be used in different deliverables and so should be available in some common or core library
  2. It may make sense for your components to talk to an Address interface, and the implementation can be provided separately (e.g. provide an Address interface and an AddressImpl implementation). This will reduce the amount of binding between the core library and the library your developers will develop.
Brian Agnew
thanks Brian, for the interface advice as well
DJC
Please call it `DefaultAddress` rather than `AddressImpl`. `*Impl` implies it is the one (and only) implementation, which makes the use of an interface, well... senseless. `Default*` states what it is, the default implementation.
Willi
+1  A: 

I suggest you don't "Deliver" these jars separately. Java has very subtle versioning issues that you don't want to run into. Build everything together and package it into one or two jars and always deliver both jars, or build them together and deliver a subset of jars (but never combine new and old jars--don't just try to send a single jar as an update).

If you must build them separately be very aware that final constants are compiled in and not referenced--so if you change one and deliver a new jar, any references from an older jar will not be updated.

Also method signatures that change will have strange, unpredictable results.

It sounds like you want a developer interface as well--that may be a set of interfaces and classes that reside in a separate jar. If you make that one jar well enough that you never have to rev it (and, of course, with no references to external constants) you can probably get away with not updating it which will keep your customer's extensions from getting crusty.

Bill K
thanks Bill for saving me some misery :)
DJC