Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change convention for intent key extras #93

Open
palbp opened this issue Apr 7, 2021 · 0 comments
Open

Change convention for intent key extras #93

palbp opened this issue Apr 7, 2021 · 0 comments
Assignees

Comments

@palbp
Copy link
Contributor

palbp commented 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)

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!

@palbp palbp changed the title Change convention for naming intent key extras Change convention for intent key extras Apr 7, 2021
@Jtoliveira Jtoliveira self-assigned this Apr 14, 2021
Jtoliveira added a commit that referenced this issue May 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants