[SERVER-4631] Copy try.mongodb.org in to tutorial() function in shell Created: 06/Jan/12  Updated: 06/Dec/22  Resolved: 16/Nov/16

Status: Closed
Project: Core Server
Component/s: Shell
Affects Version/s: None
Fix Version/s: None

Type: New Feature Priority: Minor - P4
Reporter: Mathias Stearn Assignee: Backlog - Storage Execution Team
Resolution: Won't Fix Votes: 0
Labels: neweng
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Assigned Teams:
Storage Execution
Participants:

 Description   

Would be a nice way to get people started. Would also be cool to add some optional modules such as tutorial_mr(), tutorial_geo() etc.



 Comments   
Comment by siddharth.singh@10gen.com [ 09/May/12 ]

Hey Nosh,

Andy and I had a chat about this and though this is a good proposal, our shell code as of now is not very extensible and including more things to the global namespace might not be a very good idea. We need to clean up our shell code first, before merging anything new to it. Refactoring will also make it easier going forward to add optional modules such as tutorial_mr(), tutorial_geo() as you suggested.

I am going to mark this as 'Won't fix' and close it. If you feel strongly that we should have this feature in our shell we can always revisit this.

Thanks.

Comment by siddharth.singh@10gen.com [ 29/Feb/12 ]

LGTM.

Comment by nosh petigara [ 17/Feb/12 ]

changed it to use postfix++

but the reason why I usually use variable = variable + 1 is that it always clear to me what the intention of the series of commands is

https://github.com/nosh/mongo/commit/37e2298244a7fb6aa2f2818ebbf9ac3dd45d5910

Comment by Mathias Stearn [ 15/Feb/12 ]

Please use postfix ++/-- especially when updating a member:

currentTutorial.currentState++;

rather than:

++currentTutorial.currentState;

since you are not incremental currentTutorial.

Edit: to clarify, this is stylistic not syntastic.

Comment by siddharth.singh@10gen.com [ 14/Feb/12 ]

@nosh : some optional remarks:

1) No spaces between the keyword function and the first parenthesis. So function() but not function (). I see both the styles in the same file. In just your piece of code, you mixed these styles too. To me, function() looks easier to read.

2) currentTutorial.currentState = currentTutorial.currentState + 1; could be shorthanded to ++currentTutorial.currentState; Improves readability.

3) currentTutorial.currentState = currentTutorial.currentState - 2; could be shorthanded to currentTutorial.currentState -= 2; I was also curious why you subtract 2 and then increment by 1 instead of directly decrementing by 1. I could not think of any specific reason for it but may be I am missing something.

4) You might want to rename the property variable to something (for eg. chapterNo) which gives it more context. I meant to give you an example and hence used the word property.

Comment by nosh petigara [ 14/Feb/12 ]

Thanks for the suggestion - made the change in this commit:
https://github.com/nosh/mongo/commit/9c37e01f4c9158b7dc883f1ca62398967072cd7e

Comment by siddharth.singh@10gen.com [ 14/Feb/12 ]

LGTM with minor changes. Comments below:

1) Eval() should be avoided in the function shellhelper.next. The following is a better of doing it :
var property = 't' + currentTutorial.currentState;
currentTutorial[property]();

2) Same comment as (1) in shellhelper.back().

Comment by Eliot Horowitz (Inactive) [ 13/Feb/12 ]

@siddharth can you code review and if it looks good we'll merge

Comment by nosh petigara [ 13/Feb/12 ]

Running 'tutorial' starts a tutorial that go through the same steps as
http://try.mongodb.org
'next' and 'back' navigate through the tutorial

Should also be easy to add new tutorials e.g. "tutorial geo" by following the example for the basic tutorial that is in there

pull request submitted:
https://github.com/mongodb/mongo/pull/175
https://github.com/nosh/mongo/commit/f88164720c091610161658e10749edec633b6f9f

Generated at Thu Feb 08 03:06:32 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.