I am creating a service to clean up physical addresses. I have an API package that contains an interface with the cleanse method. This method will list the raw address data. Then I would have an implementation package that implements the cleanse method and provides a service. Then the client packages will depend on the set of APIs and have a link to an open service. I'm struggling to figure out the “best” way to do this. I think of two options:
Option 1:
The API package has a RawAddress value class. This means that I have a specific class in the API package that seems to me to be underestimated in the OSGI world, or at least not the best practice (see. Is it a separate OSGI set for api and general practice practice? - especially Neil comments on the accepted answer).
From the point of view of the client:
List<RawAddress> rawAddresses = new ArrayList<>();
for(...) {
RawAddress address = new RawAddress(addrLine, city, state, zip);
rawAddresses.add(address);
}
List<CleanAddress> cleanAddresses = addressService.cleanse(rawAddresses);
Option 2:
RawAddress is instead an interface in the API bundle. An AddressService object would have an additional method for creating objects that implement RawAddress. This leaves the API pool “clean,” but it also feels like it might be redundant.
From the point of view of the client:
List<RawAddress> rawAddresses = new ArrayList<>();
for(...) {
RawAddress address = addressService.newRawAddress(addrLine, city, state, zip);
rawAddresses.add(address);
}
List<CleanAddress> cleanAddresses = addressService.cleanse(rawAddresses);
It seems to me that I am thinking too much about this and / or that I do not have a better solution. Any thoughts?