0

I'm fairly new to Durandal, Knockout and Requirejs, so I wanted to ask some opinions whether my structure makes sense or not:

I've been planning to create models for my data objects, like classes in class-based languages. therefore i would be creating a folder models in which I'd define modules like student (transient, holds one students data) and students (singleton, holding array of student objects and functions for adding, removing, etc).

These modules I would then require in my ViewModels (e.g. admin/students for the administration area, user/student where the data for one student is loaded... etc...)

Does this make sense or would it be better to just put everything into one module and define students and student in every viewModel? I'm a little lost on how to leverage reusable code here.

Martin
  • 1,112
  • 1
  • 11
  • 31
  • An interesting question, but not quite a good fit for SO. You could try CodeReview.SE, but do check their FAQ, AFAIK they require you show working code (so just have a go at a certain design, and put it up there for review). – Jeroen Jun 25 '15 at 06:46
  • Definetely makes sense as an architecture... anyway I must agree with @Jeroen. – Andrea Casaccia Jun 25 '15 at 08:46
  • Ok. Thanks anyway for the input! – Martin Jun 25 '15 at 08:51
  • 1
    It reminds me of what I did in Angular.js with services. Angular.js dependency injection is similar to what you can do with Require.js. I guess it would be overkill for you to learn Angular.js only to have an idea of how to structure your application, but you could consider having a look at their documentation. – Andrea Casaccia Jun 25 '15 at 09:16

0 Answers0