Is it wrong to use Deprecated methods or classes in Java?

1. Is it wrong to use Deprecated methods or classes in Java? From the definition of 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. The method is kept in the API for backward compatibility for an unspecified period … Read more

Observer is deprecated in Java 9. What should we use instead of it?

Why is that? Does it mean that we shouldn’t implement observer pattern anymore? Answering the latter part first – YES, it does mean you shouldn’t implement Observer and Obervables anymore. Why were they deprecated – They didn’t provide a rich enough event model for applications. For example, they could support only the notion that something … Read more

Is `shouldOverrideUrlLoading` really deprecated? What can I use instead?

Documenting in detail for future readers: The short answer is you need to override both the methods. The shouldOverrideUrlLoading(WebView view, String url) method is deprecated in API 24 and the shouldOverrideUrlLoading(WebView view, WebResourceRequest request) method is added in API 24. If you are targeting older versions of android, you need the former method, and if … Read more

The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead [duplicate]

Why is this happening? The entire ext/mysql PHP extension, which provides all functions named with the prefix mysql_, was officially deprecated in PHP v5.5.0 and removed in PHP v7. It was originally introduced in PHP v2.0 (November 1997) for MySQL v3.20, and no new features have been added since 2006. Coupled with the lack of … Read more

Environment.getExternalStorageDirectory() deprecated in API level 29 java

Use getExternalFilesDir(), getExternalCacheDir(), or getExternalMediaDirs() (methods on Context) instead of Environment.getExternalStorageDirectory(). Or, modify mPhotoEditor to be able to work with a Uri, then: Use ACTION_CREATE_DOCUMENT to get a Uri to a location of the user’s choosing, or Use MediaStore, ContentResolver, and insert() to get a Uri for a particular type of media (e.g., an image) … Read more

BaseException.message deprecated in Python 2.6

Solution – almost no coding needed Just inherit your exception class from Exception and pass the message as the first parameter to the constructor Example: class MyException(Exception): “””My documentation””” try: raise MyException(‘my detailed description’) except MyException as my: print my # outputs ‘my detailed description’ You can use str(my) or (less elegant) my.args[0] to access … Read more

How to manually deprecate members

You can use the Available tag, for example : @available(*, deprecated) func myFunc() { // … } Where * is the platform (iOS, iOSApplicationExtension, macOS, watchOS, tvOS, * for all, etc.). You can also specify the version of the platform from which it was introduced, deprecated, obsoleted, renamed, and a message : @available(iOS, deprecated:6.0) func … Read more

decorators in the python standard lib (@deprecated specifically)

Here’s some snippet, modified from those cited by Leandro: import warnings import functools def deprecated(func): “””This is a decorator which can be used to mark functions as deprecated. It will result in a warning being emitted when the function is used.””” @functools.wraps(func) def new_func(*args, **kwargs): warnings.simplefilter(‘always’, DeprecationWarning) # turn off filter warnings.warn(“Call to deprecated function … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)