Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Spike] Give bottom-up examples in Controllers.md, Routes.md, Repositories.md and Decorators.md #1173

Closed
2 tasks
shimks opened this issue Mar 22, 2018 · 13 comments
Assignees
Labels
Docs OpenAPI REST Issues related to @loopback/rest package and REST transport in general Schema

Comments

@shimks
Copy link
Contributor

shimks commented Mar 22, 2018

Description / Steps to reproduce / Feature proposal

Acceptance Criteria

  • For the docs Controllers, Routes, Repositories, and Decorators
    • Replace top-down approach code (starting out with a complete spec) with an equivalent bottom-up (via the use of automatic-inference decorators like @get)
    • If there are already examples of bottom-up code that demonstrates how the artifacts are being used (potentially in Controllers and Decorators), simply delete the top-down example and bring up the bottom-up example in its place delete or move them to a less invisible place(case by case)

Quick spike

  • controllers
  • routes
    • Creating rest routes, there are 3 approaches for creating routes, the first 2 are top-down. Move the 3rd one(using decorator) up to be the first, move the other twos to the bottom, declare we don't fully support it yet.
  • repositories
  • decorators
    • api decorator, move it to the bottom and declare that it's not fully supported yet.

See Reporting Issues for more tips on writing good issues

@shimks shimks added needs discussion Docs OpenAPI Schema REST Issues related to @loopback/rest package and REST transport in general labels Mar 22, 2018
@dhmlau dhmlau added the DP3 label Apr 20, 2018
@bajtos
Copy link
Member

bajtos commented Apr 24, 2018

AFAICT, Controllers describe code-first approach too, see http://loopback.io/doc/en/lb4/Controllers.html#writing-controller-methods.

Having said that, I agree the page may need some reorganization to increase visibility of the code-first approach and decrease visibility of the design-first approach.

Similar comment applies to Decorators too - we have examples showing code-first approach, see e.g. http://loopback.io/doc/en/lb4/Decorators.html#operation-decorator.

@bajtos bajtos removed their assignment Apr 24, 2018
@virkt25 virkt25 removed their assignment Apr 24, 2018
@dhmlau
Copy link
Member

dhmlau commented May 14, 2018

I'm thinking that the code snippets shown in our documentation can be more coherent. For example, if the todo example contains most of the code we need, maybe it's a good idea to reference the code in there, i.e. copy the code snippet over and mention to users the location of a complete example can be found.

Another advantage of doing this is we do not need to spend significant amount of time to validate the code snippet for each doc, as long as we've tested the todo example (for example) is good.

@bajtos
Copy link
Member

bajtos commented May 15, 2018

We should have a tutorial showing how to build applications bottom-up way. @raymondfeng could you please add more details about what such tutorial should include? We already have Todo example, what do we need to change or add to make that example good enough as the tutorial?

@raymondfeng
Copy link
Contributor

I suggest that we create a tutorial following the narratives below:

  1. Define a controller class to describe the business functions to be exposed as REST APIs
  2. Add decorators to controller methods to map to REST endpoints
  3. Introduce a Todo model to represent the business object
  4. Introduce a TodoRepository for persistence
  5. Configure the TodoRepository with a DataSource to a database
  6. Use dependency injection to wire all things up

@bajtos
Copy link
Member

bajtos commented May 16, 2018

I suggest that we create a tutorial following the narratives below (etc.)

With the exception of the second step (add decorators to controller methods), such tutorial is already available in the top-down version here: http://loopback.io/doc/en/lb4/Implementing-features.html

We could copy that page and rework it to show bottom-up approach, but then we would end up with a lot of duplicated content.

For long term, I think we need to find a way how to show both top-down and bottom-up approaches in a way that allows us to keep shared sections in a single place.

In DP3, top-down approach is out of scope, therefore we don't need the current content in Implementing-features. I am proposing to rework that page to use bottom-up approach and maybe change it's style so that the page reads more like a tutorial than a best-practice guide.

Thoughts?

@jannyHou
Copy link
Contributor

jannyHou commented Jun 5, 2018

Let's keep discussion and revisit it in the next meeting.

@jannyHou
Copy link
Contributor

jannyHou commented Jun 6, 2018

@raymondfeng based on your comment:

I suggest that we create a tutorial following the narratives below:

1. Define a controller class to describe the business functions to be exposed as REST APIs
2. Add decorators to controller methods to map to REST endpoints
3. Introduce a `Todo` model to represent the business object
4. Introduce a `TodoRepository` for persistence
5. Configure the `TodoRepository` with a `DataSource` to a database
6. Use dependency injection to wire all things up

Do you want a new tutorial that following exactly the order from 1 to 6, meaning define controller first then the model and repository, or the order of creating artifacts doesn't matter?

If ignoring the order, I think we already have such a tutorial called "Todo Tutorial": http://loopback.io/doc/en/lb4/todo-tutorial.html

Is it the ideal tutorial for you?

@jannyHou
Copy link
Contributor

jannyHou commented Jun 6, 2018

Hi team @strongloop/sq-lb-apex @raymondfeng @bajtos @hacksparrow , after following the conversation above, I think we at least agree on make the api first approach(top-down) less visible in the 4 documentation pages list in #1173 (comment).

I would also suggest we don't document a concept in a way that the code first and api first approaches are mixed, they can be on the same page, but in two separate sections, so readers can consistently follow the supported approach to build their code, and read more about the other approach if they are interested.

Based on the current acceptance criteria, I would suggest modify it to

For the docs Controllers, Routes, Repositories, and Decorators

  • Use code first(bottom-up) approach to build app across all concepts/artifacts
    • If the document is already written in that way, keep it
    • If the document has api first approach(top-down), replace it with the code first example(via the use of automatic-inference decorators like @get).
  • If there are already examples of bottom-up code that demonstrates how the artifacts are being used (potentially in Controllers and Decorators), move them to a more visible section.
    • Do our best to reduce the duplicate code

Thought?

@bajtos
Copy link
Member

bajtos commented Jun 7, 2018

If there are already examples of bottom-up code that demonstrates how the artifacts are being used (potentially in Controllers and Decorators), move them to a less visible section.

I think you meant top-down code examples should be moved to less visible sections?

The proposal looks good to me. To be honest, I think it would be more effective to sandbox this task to a certain amount of time and let the person working on the task to decide what's best, rather than spend so much time and effort on coming up with clear acceptance criteria.

@jannyHou jannyHou changed the title Give bottom-up examples in Controllers.md, Routes.md, Repositories.md and Decorators.md [Spike] Give bottom-up examples in Controllers.md, Routes.md, Repositories.md and Decorators.md Jun 7, 2018
@jannyHou
Copy link
Contributor

jannyHou commented Jun 7, 2018

From last estimation meeting:
Let's do a quick spike:

  • Take a look of the 4 pages in story description, list the sections
    • out of date, need to remove
    • out of date, need to replace

@jannyHou
Copy link
Contributor

  • controllers
  • routes
    • Creating rest routes, there are 3 approaches for creating routes, the first 2 are top-down. Move the 3rd one(using decorator) up to be the first, move the other twos to the bottom, declare we don't fully support it yet.
  • repositories
  • decorators
    • api decorator, move it to the bottom and declare that it's not fully supported yet.

I agree with @bajtos in comment #1173 (comment), while a quick spike would also give the story owner a much clear scope, so I did the quick spike as we discussed last time.
cc @strongloop/sq-lb-apex @hacksparrow @raymondfeng @bajtos

@dhmlau
Copy link
Member

dhmlau commented Jun 25, 2018

@jannyHou , so your above comment is the acceptance criteria of this task?

@dhmlau
Copy link
Member

dhmlau commented Jul 11, 2018

#1512 #1513 #1514 #1515 are created as the outcome of the spike.
closing this spike as done.

@dhmlau dhmlau closed this as completed Jul 11, 2018
@shimks shimks added this to the July Milestone milestone Jul 31, 2018
@bajtos bajtos added the p1 label Aug 13, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Docs OpenAPI REST Issues related to @loopback/rest package and REST transport in general Schema
Projects
None yet
Development

No branches or pull requests

8 participants