Difference between a deprecated and a legacy API?

后端 未结 7 2247
予麋鹿
予麋鹿 2020-11-30 03:22

I was studying the legacy API\'s in the Java\'s Collection Framework and I learnt that classes such as Vector and HashTable have been

相关标签:
7条回答
  • 2020-11-30 03:38

    Deprecation often denotes that there is an intention to remove the functionality at some point in the future, whereas legacy just implies it shouldn't be used in new code if at all possible (though may even then be needed for interop reasons).

    0 讨论(0)
  • 2020-11-30 03:42

    My interpretation is that Legacy code simply has newer counterparts that do the job better. It will, however, continue to receive bug fixes and other support. Deprecated code, on the other hand, is unsupported and won't receive dedicated bug fixes.

    0 讨论(0)
  • 2020-11-30 03:45

    Deprecation means that it's bad and shouldn't be used - File.toURL() is a prime example, since it doesn't create correct URLs from files with spaces in the path. It's simply not doing what it should, but since existing code might be using workarounds which would break if the bug was fixed

    Legacy just means that it's old and there are ways of doing something which are generally, but not necessarily, better. Vector is a good example - it is a List implementation, but it's still got some ugly crap from the days before the Collections API (i.e., List) was designed. It is also synchronized, which means that you have to pay the synchronization fee even when using it in a single-threaded scenario (except for in some situations where the VM is clever). ArrayList is better if you want an array-backed list implementation since it's unsynchronized, and Collections.synchronizedList is more flexible when you want a synchronized list since it's a wrapper which can be used with all list implementations (linked lists, lists from Arrays.asList(T...), etc). However, if you do happen to want a synchronized, array-backed list implementation, then Vector is fine.

    0 讨论(0)
  • 2020-11-30 03:47

    A common interpretation is that Deprecated means that it will be removed in the near future, and Legacy means that it will remain for backwards compatibility or other reasons.

    Both mean that they shouldn't be used by new code.

    In the case of the JDK even Deprecated code will remain, since backwards compatibility is very important for the Java JDK.

    0 讨论(0)
  • 2020-11-30 03:50

    I have a suggestion - legacy refers to code that was written in the past, deprecated refers to the advice not to use it anymore. You can still use deprecated api, but you can't write legacy code, cuz you're writing it right now. Just IMHO

    0 讨论(0)
  • 2020-11-30 03:55

    The Deprecated annotation gives a formal definition of a deprecated API. I don't think that a formal definition for legacy classes exists. Both actually mean that the class shouldn't be used in new code.

    0 讨论(0)
提交回复
热议问题