- You find yourself asking, "I need to arrange some interactions. What should I call the players and the interaction?"
- For each interaction
- Ask "What message do I want to send?"
- Ask "To whom should I send it?" Be as specific as possible.
changePasswordgoes to thePasswordChanger. - Ask "Is there already another recipient that is enough like this one that I am comfortable combining them?" If so, do.
I'm considering refactoring a number Ember.Components that have API interactions to use one or more API service objects. I'm concerned with the layer violation: making API calls in the view layer.
- "change password"
changePassword(old, new) -> PromisePasswordChanger.changePassword(old, new)- Nope
- "reset password"
resetPassword() -> PromisePasswordResetter.resetPassword()- Yeah!
PasswordModifier.changePassword, and.resetPassword - "check two-factor token during sign-in"
checkTwoFactorAuth(code) -> PromiseTwoFactorChecker.checkTwoFactorAuth(code)- Maybe.
AuthenticationManagerfits all three, but it's pretty vague. I probably would combine these, but it's not as clear a win.
With this algorithm, you could get different results depending on the order in which you consider the interactions. A hill-climbing approach would be
- For each interaction
- Ask "What message do I want to send?" (same as above)
- Ask "To whom should I send it?" Be as specific as possible.
changePasswordgoes to thePasswordChanger. (same as above)
- Map from
Recipient.messagepairs to combined recipient name - Choose the most obvious, clear combined name
- If you like combining them
- do
- put the new name back in the pool
- choose another name
In the passwords-and-two-factor-tokens case, I'd end up with the same result. It would probably differ (and therefore be a more interesting discussion among the team) with more input interactions.