donejs / generator-donejs

A Yeoman generator for your DoneJS application
MIT License
9 stars 7 forks source link

Generate supermodels inside modlets #114

Open justinbmeyer opened 8 years ago

justinbmeyer commented 8 years ago

The current supermodel generator creates a the model and its test in the models folder, and a fixture file in the fixtures folder as follows:

├── todo.js
├── todo_test.js
├── fixtures/
|   └── todo.js

Unlike components, this does not use modlets.

Pros:

Cons:

├── todo/
|   ├── todo.js
|   ├── todo_test.js
|   ├── test.html
|   └── todos.js (this would be the fixture)

Considerations:

├── todo/
|   ├── todo.js
|   ├── todo_test.js
|   ├── test.html
|   └── todo_fixture.js 

Modlet with fixture out

├── fixtures/
|   └── todo.js
├── todo/
|   ├── todo.js
|   ├── todo_test.js
|   └── test.html
JaneOri commented 8 years ago

I'm in favor of the "Modlet with fixture" approach.

The modlet approaches also give us a good place for a demo.html if we decide we want/need one.

justinbmeyer commented 7 years ago

Also related: https://github.com/donejs/donejs/issues/509

Alfredo-Delgado commented 7 years ago

My 2 cents:

What's most important when dealing with models is recognizing that they are a horizontal concern spanning the entire project, like design, as opposed to disparate strata in vertical feature implementations.

With this in mind, how models are organized should take into account individual model requirements vs. datasource requirements. e.g.

Edit: Modlet with fixture out jibes best with this line of thinking.

BigAB commented 7 years ago

@Alfredo-Delgado You think the Datasource and related should be separate from the Model?

I am trying to think of a use case....

I can't think of one, why wouldn't it be:

What is the benefit of splitting out the connection and behaviours? Would they be shared by multiple models somehow?

Alfredo-Delgado commented 7 years ago

@BigAB, hierarchically speaking, this is what we're dealing with.

If you wrote your own behavior to address something about Datasource then you would incorporate it into your own connection factory (i.e. your version of superMap) and it would be shared among that datasource's models.

Your datasource might support different kinds of connections. Maybe you want one without your special behavior, or one with your special behavior but no caching, etc.