-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Atlas search POC #956
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
Atlas search POC #956
Changes from all commits
5c80dab
1c22dcf
8f90467
c711b90
26a604b
93f30b8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,6 +13,8 @@ | |
| * limitations under the License. | ||
| */ | ||
|
|
||
| using MongoDB.Driver.Search; | ||
|
|
||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Lots of irrelevant refactoring in this file. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good opportunity for minor refactoring. For example if staying with fields, |
||
| namespace MongoDB.Driver | ||
| { | ||
| /// <summary> | ||
|
|
@@ -21,50 +23,29 @@ namespace MongoDB.Driver | |
| /// <typeparam name="TDocument">The type of the document.</typeparam> | ||
| public static class Builders<TDocument> | ||
| { | ||
| private static FilterDefinitionBuilder<TDocument> __filter = new FilterDefinitionBuilder<TDocument>(); | ||
| private static IndexKeysDefinitionBuilder<TDocument> __index = new IndexKeysDefinitionBuilder<TDocument>(); | ||
| private static ProjectionDefinitionBuilder<TDocument> __projection = new ProjectionDefinitionBuilder<TDocument>(); | ||
| private static SortDefinitionBuilder<TDocument> __sort = new SortDefinitionBuilder<TDocument>(); | ||
| private static UpdateDefinitionBuilder<TDocument> __update = new UpdateDefinitionBuilder<TDocument>(); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I disagree with removing private backing fields. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this is a classic usage for auto properties. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. My counter argument is that most of our classes already have private fields using the In many cases (such as when validating in setters) an explicit backing field is required. Why not just standardize on explicit backing fields and that way we can always know by glancing at the top of a class what state the class maintains. Otherwise we have to tediously search the source file to see if there are any autoproperties we didn't know about. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think the key here is finding a good balance between following the existing style and evolving our code base to use new language features and mainstream standards. We have already adopted some mainstream conventions like string interpolation, Like with fields, all properties (auto implemented or not) through the source file, they will always reside in same section, like fields. Given that, and the fact the major part of code is cleaned up, the "state" of the class appears more clear to me. Autoproperties indicate that this is just a simple data holders, no custom properties, no special relation between property and field that needs to be inspected. For more complicated classes, where inspecting class state/functionality becomes is more complicated, and I find using VS built-in class/document explorers very useful. |
||
| /// <summary>Gets a <see cref="FilterDefinitionBuilder{TDocument}"/>.</summary> | ||
| public static FilterDefinitionBuilder<TDocument> Filter { get; } = new FilterDefinitionBuilder<TDocument>(); | ||
|
|
||
| /// <summary>Gets an <see cref="IndexKeysDefinitionBuilder{TDocument}"/>.</summary> | ||
| public static IndexKeysDefinitionBuilder<TDocument> IndexKeys { get; } = new IndexKeysDefinitionBuilder<TDocument>(); | ||
|
|
||
| /// <summary>Gets a <see cref="ProjectionDefinitionBuilder{TDocument}"/>.</summary> | ||
| public static ProjectionDefinitionBuilder<TDocument> Projection { get; } = new ProjectionDefinitionBuilder<TDocument>(); | ||
|
|
||
| /// <summary> | ||
| /// Gets a <see cref="FilterDefinitionBuilder{TDocument}"/>. | ||
| /// </summary> | ||
| public static FilterDefinitionBuilder<TDocument> Filter | ||
| { | ||
| get { return __filter; } | ||
| } | ||
| /// <summary>Gets a <see cref="SortDefinitionBuilder{TDocument}"/>.</summary> | ||
| public static SortDefinitionBuilder<TDocument> Sort { get; } = new SortDefinitionBuilder<TDocument>(); | ||
|
|
||
| /// <summary> | ||
| /// Gets an <see cref="IndexKeysDefinitionBuilder{TDocument}"/>. | ||
| /// </summary> | ||
| public static IndexKeysDefinitionBuilder<TDocument> IndexKeys | ||
| { | ||
| get { return __index; } | ||
| } | ||
| /// <summary>Gets an <see cref="UpdateDefinitionBuilder{TDocument}"/>.</summary> | ||
| public static UpdateDefinitionBuilder<TDocument> Update { get; } = new UpdateDefinitionBuilder<TDocument>(); | ||
|
|
||
| /// <summary> | ||
| /// Gets a <see cref="ProjectionDefinitionBuilder{TDocument}"/>. | ||
| /// </summary> | ||
| public static ProjectionDefinitionBuilder<TDocument> Projection | ||
| { | ||
| get { return __projection; } | ||
| } | ||
| // Search builders | ||
| /// <summary>Gets a <see cref="PathDefinition{TDocument}"/>.</summary> | ||
| public static PathDefinitionBuilder<TDocument> Path { get; } = new PathDefinitionBuilder<TDocument>(); | ||
|
|
||
| /// <summary> | ||
| /// Gets a <see cref="SortDefinitionBuilder{TDocument}"/>. | ||
| /// </summary> | ||
| public static SortDefinitionBuilder<TDocument> Sort | ||
| { | ||
| get { return __sort; } | ||
| } | ||
| /// <summary>Gets a <see cref="ScoreDefinitionBuilder{TDocument}"/>.</summary> | ||
| public static ScoreDefinitionBuilder<TDocument> Score { get; } = new ScoreDefinitionBuilder<TDocument>(); | ||
|
|
||
| /// <summary> | ||
| /// Gets an <see cref="UpdateDefinitionBuilder{TDocument}"/>. | ||
| /// </summary> | ||
| public static UpdateDefinitionBuilder<TDocument> Update | ||
| { | ||
| get { return __update; } | ||
| } | ||
| /// <summary>Gets a <see cref="SearchDefinitionBuilder{TDocument}"/>.</summary> | ||
| public static SearchDefinitionBuilder<TDocument> Search { get; } = new SearchDefinitionBuilder<TDocument>(); | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This refactoring changes the error message a tiny bit. Could be considered a breaking change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same might apply to some of the other refactorings.
Do we really want one Ensure method calling another? Or should each Ensure method be complete by itself?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think code reuse makes things simpler and cleaner, where appropriate.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Of course! But it changes the error messages.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's a very minor change in this case.
We also need to change messages in
IsNullOr*anyway at some point.