In my Eclipse Android App I use type Date. I am warned that this is a deprecated type. Does this mean I cannot use it, or merely that it is bad practice to?
Thanks for the help!!
In my Eclipse Android App I use type Date. I am warned that this is a deprecated type. Does this mean I cannot use it, or merely that it is bad practice to?
Thanks for the help!!
Essentially deprecated is a warning to you as a developer that while the method/class/whatever is there and works it is not the best way to do it. Either a newer and better alternative is available or (sometimes) there is something subtly broken about it that makes it not advisable to use.
You can still use deprecated things - but you should look to see why they are deprecated first and see if the new way of doing things is better for you.
In theory deprecated things can or will in future be removed. That rarely happens (some Java libraries have deprecated stuff in them that is more than ten years old) but is a risk you should be aware of.
Sure you can use it now, but it might be removed in the future. Better look for alternatives. You can also pack it into a library yourself, so you don't have to rely on the standard library.
You can (we will not cut your hands, because we can't ;)), but it's a bad practice. They're always given newer substitutions, which you should use.
In the future deprecated functions can be removed, so your code can stop to work.
If stopping to use the deprecated method doesn't break backward compatibility I prefer to move to new API, nothing is mandatory but the effort is so small that I prefer to have code without warnings
Old functions are sometimes retained alongside the newer functions designed to replace them for backwards compatibility. Such functions will often be marked "deprecated" to make this clear.
I disagree that it is always "bad practice" to use deprecated functions. If it were bad practice, they would not have been deprecated, the would have been removed. Existing code that makes use of deprecated functions is usually okay if left alone, but may require a refactor to make use of newer versions of a 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. I have never seen a function marked "deprecated" without having been replaced with some newer, usually better, alternative. New code should make use of the updated function which will often contain important optimizations, design changes, or bug fixes.
The second: it's just considered BAD PRACTICE. But still working (in the NEAR future - for the FAR future it's not guaranteed working anymore).
You're discouraged to use it, but you can.
It depends on the reason why it was deprecated. Read javadocs. For example it makes no sense to use Thread.destroy
/**
* Throws {@link NoSuchMethodError}.
*
* @deprecated This method was originally designed to destroy this
* thread without any cleanup. Any monitors it held would have
* remained locked. However, the method was never implemented.
* If if were to be implemented, it would be deadlock-prone in
* much the manner of {@link #suspend}. If the target thread held
* a lock protecting a critical system resource when it was
* destroyed, no thread could ever access this resource again.
* If another thread ever attempted to lock this resource, deadlock
* would result. Such deadlocks typically manifest themselves as
* "frozen" processes. For more information, see
* <a href="{@docRoot}/../technotes/guides/concurrency/threadPrimitiveDeprecation.html">
* Why are Thread.stop, Thread.suspend and Thread.resume Deprecated?</a>.
* @throws NoSuchMethodError always
*/
@Deprecated
public void destroy() {
throw new NoSuchMethodError();
}
You can use it for now, but it may be completely discarded in the future. This means that someone would have to be using the JVM of the version of java that you made this with, which is unlikely. You should only use it if your users can get updates for your program.