Hi Mike, The change you need to make depends on the contract for your hashCode() method. Whatever you change you really should change your version. API should really only use the same version if it’s bit identical. I would normally not bother to change the version when just using a different compiler, but even that is technically a change.
If you have made the mistake of specifying the hashing function (they nearly did this with String in Java) then: Changing the implementation in a way which changes the returned value is a breaking change, and would be a MAJOR version bump Changing the implementation in a way which doesn’t change the returned value breaks no-one, and would be a MICRO change If you have stuck with the standard hash code contract, which means that the algorithm isn’t part of your API, then: Changing the implementation in a way which changes the returned value is *not* a breaking change as nobody should rely on it. This makes it a MICRO change. Changing the implementation in a way which doesn’t change the returned value still breaks no-one, and would be a MICRO change As for your other questions, it’s hard to talk specifics without more detail, but… In general if value objects are part of your API then you should expose them directly as API. Factories are often superfluous in this situation, but it does depend on context. Value objects in general are a “Good Thing”, and if you make sure they really are value objects (final, immutable, serialisable in some way, and with no behaviours) then they make Remote Services work really easily and well. Regards, Tim On 29 Sep 2014, at 10:27, Mike Wilson <[email protected]> wrote: > What's your best practice when changing value object classes? > > Consider: > > myservice-api-1.0.0.jar > META-INF/MANIFEST.MF > Export-Package: myservice;version="1.0" > public interface MyService { > void doStuffWithValue(MyValue v) ... > MyValue returnValue() ... > } > public class MyValue { > String member1; > int member2; > public boolean equals(Object obj) ... > public int hashCode() ... > } > > myservice-impl-1.0.0.jar > class MyServiceImpl implements MyService { > ... > } > > Now if I need to update the implementation of MyValue's > hashCode method, what would you do? > - not update API version > - update API version > - wrong design, use a factory pattern for MyValue > - wrong question, you should avoid value objects altogether > - <other suggestions> > > Thanks > Mike Wilson > > _______________________________________________ > OSGi Developer Mail List > [email protected] > https://mail.osgi.org/mailman/listinfo/osgi-dev
_______________________________________________ OSGi Developer Mail List [email protected] https://mail.osgi.org/mailman/listinfo/osgi-dev
