javascript - Marionette Controller Function Declarations - Best Practices -


i'm writing large scale marionette application, ran router / controller.

here's question -- practice include other functions in controller aren't meant routes?

so have following method:

index : function() {    alert('test!'); } 

is consistent best practices able declare other functions in controller not called when routes initialized? so:

norouteassociated: function() {      alert('test!'); }  index: function() {      this.norouteassociated(); } 

obviously simplified example, trying avoid putting large amounts of information or function declarations inside of methods because they're associated routers.

the roles , responsibilities of controllers best illustrated @davidsulc in this post , better yet new book.

generally speaking, it's okay include methods aren't meant routes, if they're controlling workflow of app. event triggering example, if want change appearance of or retrieve data database, should move these methods view or model, respectively. block quote below taken directly marionette's controller documentation.

the name controller bound cause bit of confusion, rather unfortunate. there discussion , debate call object, idea people confuse mvc style controller came number of times. in end, decided call controller anyways, typical use case control workflow , process of application , / or module.

but truth is, generic, multi-purpose object can serve many different roles in many different scenarios. open suggestions, reason , discussion, on renaming objects more descriptive, less confusing, etc. if suggest different name, please in either mailing list or github issues list.


Comments

Popular posts from this blog

ios - UICollectionView Self Sizing Cells with Auto Layout -

node.js - ldapjs - write after end error -

DOM Manipulation in Wordpress (and elsewhere) using php -