2
\$\begingroup\$

How could this code be improved and have fewer repeated lines?

vent.on("createAccountLayout:rendered", function() {
    logger.info('createAccountLayout:rendered => CreateAccountLayoutController');
    showRegion(['phoneNumberRegion', 'keyboardRegion', 'nextRegion', 'quitRegion']);

    vent.trigger('createAccountLayout:setToNumericKeyboard');
});

vent.on('createAccountPhoneNumberView:nextStep', function() {
    closeRegion(['phoneNumberRegion', 'keyboardRegion', 'nextRegion']);
    showRegion(['nameRegion', 'keyboardRegion', 'nextRegion']);

    vent.trigger('createAccountLayout:setToAlphaNumericKeyboard');
    vent.trigger('createAccountLayout:disableNextButton');
});
\$\endgroup\$
  • 1
    \$\begingroup\$ If the code isn't that repetitive or that many, I suggest you leave it be. This is too little for a generic routine to be created. \$\endgroup\$ – Joseph May 23 '13 at 2:52
  • \$\begingroup\$ Noted. Though while coding this module, I realized that there's going to be more of those. So I want to simplify this before things gets out of hand. \$\endgroup\$ – user1966211 May 23 '13 at 3:00
  • 1
    \$\begingroup\$ As far as I remember, I have answered a question of yours that holds the same pattern. You can apply a similar approach. \$\endgroup\$ – Joseph May 23 '13 at 3:07
2
\$\begingroup\$

Answerifying what Joseph the Dreamer commented on,

there is really not enough code to build a general routine out of, the code is fine as is. Though ideally you could add comments.

| improve this answer | |
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.