Application Module Architecture

Ryan Adams edited this page Feb 7, 2014 · 1 revision
Clone this wiki locally

Authoring Tool Front-end Architecture

Transcript of a Skype Chat discussing our approach

[07/02/2014 14:05:14] Kevin Corry: should we rename the templates to have 'view' on the end? ie dashboardView
[07/02/2014 14:05:33] Kevin Corry: so that the view class can just use the constructor name to pick up which template to use?
[07/02/2014 14:07:07] Brian Quinn: i can see how that would make it handier to infer the template from the view name
[07/02/2014 14:07:34] Brian Quinn: but it could read to confusion in the fact that you'd have dashboardView.hbs and dashboardView.js
[07/02/2014 14:07:44] Brian Quinn: or not
[07/02/2014 14:08:03] Brian Quinn: is it a good convention that each view has a corresponding template?
[07/02/2014 14:08:29] Kevin Corry: I think it might be, dashboard.hbs is near enough the same thing
[07/02/2014 14:09:19] Ryan Adams: is there a one to one mapping between a view and the template?
[07/02/2014 14:09:42] Ryan Adams: does CourseView.js handle lists of courses as well as showing a single course?
[07/02/2014 14:09:54] Ryan Adams: (forgive my ignorance of the framework)
[07/02/2014 14:10:27] Ryan Adams: i can imagine that we might have admin-dashboard.hbs and user-dashboard.hbs for example.
[07/02/2014 14:11:21] Brian Quinn: in that case Ryan, dashboard.hbs could support different roles in the template
[07/02/2014 14:11:50] Brian Quinn: with some kind of {{if isAdmin }}
[07/02/2014 14:11:51] Brian Quinn: or something
[07/02/2014 14:11:53] Ryan Adams: but maybe templates shouldn't have logic like that?
[07/02/2014 14:13:04] Kevin Corry: or you could instantiate it with 

new DashboardView({template:'admin-dashboard'});
new DashboardView({template:'user-dashboard'});

depending on what you're rendering?
[07/02/2014 14:13:32] Kevin Corry: or have an AdminDashboardView class?
[07/02/2014 14:13:47] Daryl Hedley: do the logic way man - it's what hanldebars was built for
[07/02/2014 14:13:56] Daryl Hedley: plus jade templates do a similar thing
[07/02/2014 14:14:18] Daryl Hedley: I think putting view at the end allows you separate them out into proper modules
[07/02/2014 14:14:31] Daryl Hedley: (which I think the files should be placed)
[07/02/2014 14:14:36] Daryl Hedley: so you might have
[07/02/2014 14:14:53] Ryan Adams: i don't think you need "view" as the .hbs makes it clear what it is.
[07/02/2014 14:15:00] Daryl Hedley: dashboard/
[07/02/2014 14:15:02] Daryl Hedley: etc
[07/02/2014 14:15:37] Ryan Adams: i think the module approach is sensible.
[07/02/2014 14:15:51] Kevin Corry: The guys had an idea of picking up the corresponding hbs based on the current class, that's where this was coming from
[07/02/2014 14:16:02] Ryan Adams: i think kevin's suggestion is good too, but perhaps there's a default option which maps to the name of the current class
[07/02/2014 14:16:27] Ryan Adams: so if you don't provide the "template" option in the constructor it falls back to classname
[07/02/2014 14:16:34] Daryl Hedley: what about having it like the extensions in the framework
[07/02/2014 14:16:49] Daryl Hedley: so you have the folder structure above and files like this
[07/02/2014 14:17:47] Daryl Hedley: dashboard/
[07/02/2014 14:17:55] Daryl Hedley: only thing with this is the console.logs
[07/02/2014 14:18:08] Daryl Hedley: if I have a console or error and I want to debug it
[07/02/2014 14:18:18] Daryl Hedley: supposedly it's in dashboard.js
[07/02/2014 14:18:21] Daryl Hedley: which one?
[07/02/2014 14:19:14] Brian Quinn: i'm not sure about that structure
[07/02/2014 14:19:23] Ryan Adams: hmm, models have wider use than single extensions
[07/02/2014 14:19:43] Ryan Adams: a Course model is going to be used in Dashboard, Course, Publish, (making these extensions up)
[07/02/2014 14:20:53] Daryl Hedley: yeah but there should be one place you look for them - either in a models folder - which will get overwhelming and far too many files
[07/02/2014 14:20:59] Daryl Hedley: or in the inidivudal module folders
[07/02/2014 14:21:49] Brian Quinn: i'm happy enough for them to be in a Models folder, but i think we should append the fact that it's a Model to the filename
[07/02/2014 14:22:18] Brian Quinn: for debugging, as you said
[07/02/2014 14:22:25] Daryl Hedley: can I bring up a previous experience of doing that and suggest why it's a bad idea of putting them all in one folder
[07/02/2014 14:22:33] Brian Quinn: plus it's already convention that the class name matches the .js
[07/02/2014 14:22:33] Dennis Heaney: for the automagic template name, just submitting the fiddle again for ryan:
[07/02/2014 14:22:57] Brian Quinn: i was referring to Daryl's proposed folder structure above
[07/02/2014 14:23:11] Dennis Heaney: i also think a filename should be specific: projectModel.js, projectView.js
[07/02/2014 14:23:36] Dennis Heaney: I also think it's ok to have projectView.hbs, since we may have templates for things that aren't views
[07/02/2014 14:24:07] Dennis Heaney: what those things might be, i don't know yet - maybe partials, if my assumption about partials are correct
[07/02/2014 14:24:11] Ryan Adams: I don't like the duplication in Models/ProjectModel.js - it smells bad to me.
[07/02/2014 14:24:11] Daryl Hedley sent a file to this group:
Screen Shot 2014-02-07 at 14.23.47.png
[07/02/2014 14:24:20] Daryl Hedley: we had this in the old adapt and it's a pain
[07/02/2014 14:24:49] Ryan Adams: why?
[07/02/2014 14:25:02] Ryan Adams: is it a failure by your development environment?
[07/02/2014 14:25:11] Dennis Heaney: ryan: the class inside projectModel.js is called ProjectModel, so i think it's fair
[07/02/2014 14:25:25] Daryl Hedley: what about this
[07/02/2014 14:25:29] Ryan Adams: doesn't mean I have to like it!!
[07/02/2014 14:25:33] Dennis Heaney: more descriptive is better
[07/02/2014 14:25:35] Dennis Heaney: lol
[07/02/2014 14:25:42] Daryl Hedley: dashboard/
[07/02/2014 14:26:05] Brian Quinn: i'm happy with that too
[07/02/2014 14:26:32] Ryan Adams: of course, dashboard/js/ is duplicative...
[07/02/2014 14:26:36] Dennis Heaney: js/
[07/02/2014 14:26:37] Dennis Heaney: ?
[07/02/2014 14:26:38] Ryan Adams: Ryan Adams stops trolling
[07/02/2014 14:26:41] Dennis Heaney: lol
[07/02/2014 14:27:01] Dennis Heaney: Dennis Heaney is loving the mischievous ryan today
[07/02/2014 14:27:15] Ryan Adams: you've distracted me from my app projects...
[07/02/2014 14:27:22] Dennis Heaney: Dennis Heaney wonders if he's been drinking ...
[07/02/2014 14:27:44] Ryan Adams: just coffee and eating caramel squares...
[07/02/2014 14:27:52] Dennis Heaney: ah, sugar overload
[07/02/2014 14:28:10] Brian Quinn: i think either of the above two options is better than the current structure
[07/02/2014 14:28:25] Daryl Hedley: separate them out into modules
[07/02/2014 14:28:32] Daryl Hedley: you then know where to look faster
[07/02/2014 14:28:36] Daryl Hedley: ;-)
[07/02/2014 14:28:42] Brian Quinn: so
[07/02/2014 14:28:49] Brian Quinn: login is a module, dashboard is a module?
[07/02/2014 14:29:06] Ryan Adams: i'd say login was a behaviour of a user module
[07/02/2014 14:29:08] Daryl Hedley: yeah
[07/02/2014 14:29:16] Dennis Heaney: bingo
[07/02/2014 14:29:23] Brian Quinn: there is a forgotten password component to it too
[07/02/2014 14:29:33] Ryan Adams: dashboard might be a user module action as well actually.
[07/02/2014 14:29:46] Robert Moore: so 
[07/02/2014 14:29:48] Robert Moore: works well I'm coming round to it especially without the extra js folder
[07/02/2014 14:29:58] Brian Quinn: i like it, Rob
[07/02/2014 14:30:09] Brian Quinn: throw the login, forgot password and profile stuff in there
[07/02/2014 14:30:35] Ryan Adams: who's writing up this architecture by the way?
[07/02/2014 14:30:43] Robert Moore: lol didn't mean to edit ^
[07/02/2014 14:30:45] Daryl Hedley: I think that the way requireJS is set up suits this
[07/02/2014 14:31:05] Dennis Heaney: whoever pushes the commit that adds the structure should write the architecture doc
[07/02/2014 14:31:21] Daryl Hedley: haha
[07/02/2014 14:31:22] Dennis Heaney: eeny meeny miny moe
[07/02/2014 14:31:24] Daryl Hedley: I agree
[07/02/2014 14:31:38] Ryan Adams: i'd prefer a short description of the architecture before we start coding (even if only a short paragraph or two)
[07/02/2014 14:31:58] Ryan Adams: i don't feel qualified enough to do it though.
[07/02/2014 14:32:18] Dennis Heaney: ah, but isn't the code it's own documentation /zen
[07/02/2014 14:32:26] Ryan Adams: yes.
[07/02/2014 14:32:30] Daryl Hedley: woah...that's deep man!
[07/02/2014 14:32:34] Ryan Adams: when did you last see that work well?
[07/02/2014 14:32:41] Dennis Heaney: in anything i write
[07/02/2014 14:32:48] Dennis Heaney: that i look at again within two weeks
[07/02/2014 14:32:56] Dennis Heaney: anything outside that timeframe: never
[07/02/2014 14:33:39] Ryan Adams: do we even have a high-level description of what we're planning to do here? (node.js backend, backbone driven front-end)
[07/02/2014 14:34:03] Dennis Heaney: we have some architecture docs from last november I think
[07/02/2014 14:34:08] Robert Moore: aww the sugar overload has worn off, serious Ryan is back :(
[07/02/2014 14:34:09] Dennis Heaney: in the documentation repo
[07/02/2014 14:34:20] Ryan Adams: i'm always serious...
[07/02/2014 14:34:25] Dennis Heaney: we should update it
[07/02/2014 14:34:54] Dennis Heaney: Dennis Heaney waits for someone to ask ryan "why so serious"
[07/02/2014 14:35:25] Dennis Heaney: sorry, since ryan started doing the /me stuff i can't stop
[07/02/2014 14:35:34] Dennis Heaney: Dennis Heaney stops
[07/02/2014 14:35:44] Ryan Adams: Ryan Adams wonders whether we should all talk in asides.
[07/02/2014 14:36:24] Dennis Heaney: nope, not rising to it, ryan
[07/02/2014 14:36:34] Ryan Adams: Ryan Adams is disappointed.
[07/02/2014 14:37:10] Dennis Heaney: truly, though, I think if someone makes a pull request for the change, we can have our review of it, and then write the docs for it
[07/02/2014 14:37:38] Dennis Heaney: we should be hitting the ground running on monday, and pre-requiring the doc might slow us down