You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently extras are identified by a random key value. This should be changed across the code base. As far as I could tell, they are sometimes found in the file where the code that sends the intent is found. This is wrong!
Instead of using the approach for intent extras such as the one below (found in LoadingActivity.kt)
const val ROOT_KEY = "m0192exe1gxe12x1"
we should use a human-readable naming convention that reveals both the target component (in this case an MainActivity) and the extra's purpose. In the case of implicit intents, where the target is not predetermined, the key name should reveal its purpose. This is the approach used in the Android framework. We should stick to it.
For example, an explicit intent such as the one sent by the LoadingActivity to the MainActivity, should be defined in the MainActivity file llike this:
const val MAIN_ACTIVITY_ROOT_EXTRA = "MainActivity.Root.Extra"
We could argue that the ROOT should be named HOME instead, in the spirit of JsonHome but is issue is not about that. It is about a fundamental flaw in the design of the solution's Activities contracts. The set of Extras accepted by an Activity are a part of its public contract!
The text was updated successfully, but these errors were encountered:
palbp
changed the title
Change convention for naming intent key extras
Change convention for intent key extras
Apr 7, 2021
Currently extras are identified by a random key value. This should be changed across the code base. As far as I could tell, they are sometimes found in the file where the code that sends the intent is found. This is wrong!
Instead of using the approach for intent extras such as the one below (found in LoadingActivity.kt)
we should use a human-readable naming convention that reveals both the target component (in this case an MainActivity) and the extra's purpose. In the case of implicit intents, where the target is not predetermined, the key name should reveal its purpose. This is the approach used in the Android framework. We should stick to it.
For example, an explicit intent such as the one sent by the LoadingActivity to the MainActivity, should be defined in the MainActivity file llike this:
We could argue that the ROOT should be named HOME instead, in the spirit of JsonHome but is issue is not about that. It is about a fundamental flaw in the design of the solution's Activities contracts. The set of Extras accepted by an Activity are a part of its public contract!
The text was updated successfully, but these errors were encountered: