Would a
Contract
for deprecation be a good idea?
Take
Html.fromHtml
for example, even though we have
HtmlCompat
we wont have to go and create a
XxxCompat
for everyone if something like this was possible.
Consider this snippet:
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
Html.fromHtml(contactToDisplay, Html.FROM_HTML_MODE_LEGACY)
} else {
@Suppress("DEPRECATION") // maybe we can do something to avoid this?
Html.fromHtml(contactToDisplay)
}
If we could wrap this in a contract maybe, plus android SDKs mostly have when a particular api was deprecated, even though below a particular SDK level, it was completely fine using it.
Also, looking at a bigger picture we could maybe not just use primal checks like
implies x != null
there could be some other annotation with retention policy of runtime or something and maybe we could do
implies x is NotDeprecated::class.java
or something.
Just a thought.