Skip to content
This repository has been archived by the owner on Apr 3, 2019. It is now read-only.

Define the APIs #1

Open
almet opened this issue Jul 28, 2014 · 3 comments
Open

Define the APIs #1

almet opened this issue Jul 28, 2014 · 3 comments

Comments

@almet
Copy link
Member

almet commented Jul 28, 2014

One thing that could be interesting to look at is how they propose some dream code, really simple to use, that we could use to start with. It's all here: http://nobackend.org/dreamcode.html

@leplatrem
Copy link
Contributor

Current infinitive verbs match well with the then() semantics (start, then, get, ...). But I was thinking about providing single words and callbacks for simple read operations :

Daybed.session(server)
      .records(modeld, function(records) {
        // ...
       });
Daybed.session(server)
      .definition(modeld, function (definition) {
         // ...
      });

And use number of arguments to distinguish read / write :

var records = [{age: 3.14}, ...];
Daybed.session(server)
      .records(modeld, records, function(saved) {
          // ...
       });
var definition = {title: "tada", fields: [...]};
Daybed.session(server)
      .definition(modeld, definition, function (saved) {
          // ...
      });

Or like :

Daybed.session(server)
      .model(modeld, function (model) {
        // ...
       });
Daybed.session(server)
      .model(modeld)
      .records(function(records) {
        // ...
       });
Daybed.session(server)
      .model(modeld)
      .save(record, function (saved) {
          // ... if record.id was undefined, it was POSTed
      });

@almet
Copy link
Member Author

almet commented Sep 11, 2014

Distinguishing between read / write operations with the number of arguments sounds like a terrible idea in the first place, especially for the code reader.

It might be a cool thing for the person who's writing the code but it seems very complicated to distinguish between the read/write cases for a code reader if he doesn't know this rule about the number of arguments.

Using single words for read operations could be an idea, but I prefer explicit over implicit. My python background maybe !

@leplatrem
Copy link
Contributor

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants