Why are many Android API classes not final, although they are not explicitly documented for inheritance?

Effective Java (Joshua Bloch). Paragraph 17 reads:

"Design or document or inherit or prohibit it"

However, just a quick glance through the Android API shows that most of the API classes are not final; this is normal if they are also documented for inheritance ( Viewof Activity, for example). But there are also several non-final classes, but the documentation does not mention the inheritance of these classes. Just some arbitrary examples to illustrate my point:

  • Classes representing system services ( WifiManager, NotificationManager...)
  • Useful classes, for example UriMatcher.
  • Some hardware classes, such as Camera.

Openness and extensibility, which is the philosophy of Android, is the convention amended here? Meaning, it can be assumed that all Android API classes are intended to be inherited (regardless of whether they are explicitly documented or not); if not declared final?

+5
source share
2 answers

Only my € 0.02: the clean OO design from the book is one thing that makes the work for all possible use cases different in practice. The principles of pure design of OO sometimes have a somewhat academic character. β€œAnd maybe a little black and white.”

, , , API Android, Google: , , API .

, SW , ; .

: (: ) , "" final ( ), final ( , " " sooo [great | dugly], ") .

" , ", , : , , , , ... , .

+4

Android , , . , , .

, faux WifiManager , . WifiManager (, "" Wi-Fi ) Context.

, , , , , , , .

, , ; , .

+4

All Articles