Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to handle functions deprecation in library?

Tags:

java

api

I'm working on a Java library and would like to remove some functions from it. My reasons for this is public API and design cleanup. Some objects have setters, but should be immutable, some functionality has been implemented better/cleaner in different methods, etc.

I have marked these methods 'deprecated', and would like to remove them eventually. At the moment I'm thinking about removing these after few sprints (two week development cycles).

Are there any 'best practices' about removing redundant public code?

/JaanusSiim

like image 581
JaanusSiim Avatar asked Sep 30 '08 08:09

JaanusSiim


People also ask

What is deprecated library How do you deal with it?

A deprecated library is a library without any support. It also means that as other libraries improve (such as the rails framework), they will become incompatible with the deprecated library. If you are trying to stay current with those libraries, you might be forced to migrate to the new version.

What happens when a function is deprecated?

Deprecation, in its programming sense, is the process of taking older code and marking it as no longer being useful within the codebase, usually because it has been superseded by newer code. The deprecated code is not immediately removed from the codebase because doing so may cause regression errors.

Is it OK to use deprecated library?

It is important to point out that "deprecated" does not necessarily mean the function will cease to exist or work in a new version. It may remain working and part of the library for the lifetime of library. It is, however, bad practice to use deprecated functions in new code.

What does deprecated library mean?

In Android deprecation usually means “We will continue to support this, but we think there are better solutions”. Most of the time features are deprecated rather than immediately removed, to provide backward compatibility, and to give programmers time to bring affected code into compliance with the new standard.


2 Answers

Set a date and publicize it in the @deprecated tag. The amount of time given to the removal depends on the amount of users your code has, how well connected you are with them and the the reason for the change.

If you have thousands of users and you barely talk to them, the time frame should probably be in the decades range :-)

If your users are your 10 coworkers and you see them daily, the time frame can easily be in the weeks range.

/**
 * @deprecated
 * This method will be removed after Halloween!
 * @see #newLocationForFunctionality
 */
like image 192
Vinko Vrsalovic Avatar answered Sep 17 '22 22:09

Vinko Vrsalovic


Consider it this way, customer A downloads the latest version of you library file or frame work. He hits compile on this machine and suddenly he see thousands of errors because the member file or function does no longer exist. From this point on, you've given the customer a reason why not to upgrade to your new version and to stay with the old version.

Raymond Chen answers this the best with his blog about win32 API,

Though, our experience in our software house has been, once the API has been written we have to carry the API to the end of the product life cycle. To help users to new versions, we provide backwards compatibility with the old commands in the new framework.

like image 35
Chad Avatar answered Sep 18 '22 22:09

Chad