In the past, I used the standard way of adding @Deprecated
annotations to API methods which will be removed in a later version.
Now I am preparing a major version for a library, with many API parts removed and renamed.
To make the transition easier for existing users, maybe it could be helpful if the new library version can be used side-by-side with the old version.
Advantages
- dynamic switching between version can be implemented
- applications can fall back to the previous version if bugs are found in the new version (useful in beta phase)
To do this, I could simply move the new library version to a new package from com.mycompany.library
to com.mycompany.library.v2
Is this a common practice or are there other recommendations for such side-by-side usage of Java libraries?
Background:
the library is a simple document converter. So besides a convert(in, out) mehtod, it has many configuration properties and some event handlers. If I provide side-by-side usage, consumers could dynamically instantiate and configure them:
if (useVersion2) {
com.mycompany.library.v2.Converter c = new com.mycompany.library.v2.Converter();
// configure and run
c.setOption(...);
c.convert(in, out);
} else {
com.mycompany.library.Converter c = new com.mycompany.library.Converter();
// configure and run
c.setOption(...);
c.convert(in, out);
}
(question moved from https://stackoverflow.com/questions/37192945/)
for a short time period
. We both do know what It's temporarl means in software engineery. Doesn't we? ;-)@Deprecated
annotation to your code. Then, on the release, when people update, they'll see that code is deprecated and they should change. After that, remove the code all together.