Travis Griggs
11/06/2023, 9:02 PMonEdit
, onChange
, onClick
, onClose
) or
2) xyxAction (e.g. editAction
, changeAction
, clickAction
, closeAction
).
Is there any convention (published or not) for how others tend to name these? I feel like I should pick and stick with one or the other. Vote 1️⃣ for the first, and 2️⃣ for the second. Or answer a third type :DZach Klippenstein (he/him) [MOD]
11/06/2023, 9:11 PMon*
namesFrancesc
11/06/2023, 9:13 PMonClick
as opposed to onClicked
Travis Griggs
11/06/2023, 9:13 PMFrancesc
11/06/2023, 9:15 PMTravis Griggs
11/06/2023, 9:21 PMon
? Or are other prepositions admissable? For example, I have a startLaterAction
currently, changing that to onStartLater
makes a little less sense (to me) than whenStartLater
Francesc
11/06/2023, 9:28 PMonStartLaterClick
maybe?Travis Griggs
11/06/2023, 9:30 PMChris Fillmore
11/07/2023, 12:19 AMStylianos Gakis
11/08/2023, 2:32 PMon*
.
Like we got a chat feature, and often I name that navigateToChat: () -> Unit
and it feels quite natural.
But seeing this thread it does make me wonder that maybe I should just go ahead and start using onNavigateToChat: () -> Unit
. Consistency is a good thing in general, but I haven’t convinced myself yet 😄onNavigateToFriends
, which proves that I am undecided for no reason I think 😄Marcin Wisniowski
11/09/2023, 12:35 PMonSubmitClick
vs sendRequest
onChatButtonClick
vs navigateToChat
telling the ViewModel what event happened vs telling the ViewModel what to doStylianos Gakis
11/09/2023, 12:39 PMonSubmitClick
but then good luck understanding 5 composables down what the button click even means.Marcin Wisniowski
11/09/2023, 12:43 PMonSubmitClick
but then good luck understanding 5 composables down what the button click even means.
That sounds like a good thing. When I reuse the Composable later and the button does something else, or change the behaviour so it navigates to a confirmation screen instead of sending the request, then that’s all details that the Composable doesn’t need to know about. At that level of abstraction the submit button was clicked, what happens due to that is not it’s concern.Stylianos Gakis
11/09/2023, 12:44 PMonClick
.
The screen-specific composable, which is private
and won’t be used anywhere else, which has a hard-coded svg icon which is of a chat, will never do anything else 😄Marcin Wisniowski
11/09/2023, 12:44 PMStylianos Gakis
11/09/2023, 12:46 PMMaybe your user needs to log in to be able to use the chat feature, and so the chat button actually navigates to the login screen, etc.That’s solved on a different place anyway. The navigation to chat would happen, then the chat would figure out that they are logged out, and do the proper navigation. Just like a deep link to the chat would function the same exact way.
Marcin Wisniowski
11/09/2023, 12:47 PMThat’s solved on a different place anyway.Sure, I don’t question the naming works perfectly fine for you, just thinking about some what ifs that make me use the naming I use.
Stylianos Gakis
11/09/2023, 12:49 PMMarcin Wisniowski
11/09/2023, 12:52 PMStylianos Gakis
11/09/2023, 12:56 PMprivate
, the indirection of naming them onButtonClick
and then wondering what it does really has been a net negative in my experience.Marcin Wisniowski
11/09/2023, 1:00 PM