Colton Idle
11/30/2021, 7:20 PMsealed class GenericActionType {
class Dialer(phoneUri: String) : GenericActionType()
class Browser(url: String) : GenericActionType()
object Unknown : GenericActionType()
}
Joffrey
11/30/2021, 7:25 PMdata class
for the ones with data, it's often useful for printing/copying/equaling etc.
Regarding naming, maybe avoid "generic" and "type" in the name:
• "generic" is not advisable because nested child classes will look weird when referenced (they use the parent type): GenericActionType.Dialer(...)
• "Type" doesn't seem appropriate here because this is already a type, and that type represents an action, not an action type. If it were an action type you wouldn't have data associated with it like those urls
Maybe Action.Dial
would look betterColton Idle
11/30/2021, 7:56 PMJoffrey
11/30/2021, 8:15 PMAction
but these "generic" and "type" words didn't give more precision IMO. Maybe some words from the domain would help, like UserAction
or somethingLuke
11/30/2021, 8:39 PMGenericActionType
defines something for the subclasses, consider using sealed interface
Colton Idle
11/30/2021, 8:52 PMAdam Powell
11/30/2021, 9:01 PMJason5lee
12/01/2021, 7:36 AM