Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does it mean for a method to be deprecated? [duplicate]

A lot of threads talking about what deprecated means but not what it means for a method. Could someone please explain?

like image 442
arnold_palmer Avatar asked Feb 26 '13 04:02

arnold_palmer


People also ask

What does it mean if a method is deprecated?

A program element annotated @Deprecated is one that programmers are discouraged from using, typically because it is dangerous, or because a better alternative exists.

What does deprecated mean in API?

A deprecated API is one that you are no longer recommended to use, due to changes in the API. While deprecated classes, methods, and fields are still implemented, they may be removed in future implementations, so you should not use them in new code, and if possible rewrite old code not to use them.

How can you tell if a method is deprecated?

Preferences -> Java -> Compiler -> Errors/Warnings -> Deprecated and restricted API section. Then, each use of a deprecated method or API will show up as an error/warning in the Problems view.

What does deprecated mean in Javascript?

What does “deprecation” actually mean? First, let's start by clarifying that the deprecation is just a status applied to a software feature. It indicates that this feature should be avoided, typically because it has been superseded. Deprecation may also indicate that the feature will be removed in the future.


2 Answers

According to the Java Documentation:

A program element annotated @Deprecated is one that programmers are discouraged from using, typically because it is dangerous, or because a better alternative exists.

Basically, you can still use it but there is a safer & better way to do it now.

like image 165
Zack Avatar answered Sep 24 '22 03:09

Zack


This means that the author wants to remove this method, but didn't do this yet to not break backward compatibility. This also means, that you should not use this method, and if your are already using it, you should stop using it.

The method could be marked as deprecated because another method exists that supersedes functionality of this method, or because method is unsafe or some other reason.

like image 25
Mikhail Vladimirov Avatar answered Sep 24 '22 03:09

Mikhail Vladimirov