-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Rename mlContext.Data.TextReader() to mlContext.Data.CreateTextLoader() #1690
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
Comments
Most of our extension methods to Notable exceptions are I think that trying to prefix every factory method with In addition, I would like to ask: are we going to ever stop renaming things? |
Just saying it looks like Property objects instead of methods as it is against the C# conventions (and most languages). A method's name should have a verb describing the action being performed by that method: If we don't want to rename, it is an option, but for sure it'd be better to do it now when we are still in Preview than in the future or after v1.0 is released. |
@eerhardt @TomFinley @Zruty0 could you please discuss if we're doing this? If it's "won't fix", please close it. |
I agree that method names should be verbs (as the .NET design guidelines state). This guideline doesn't seem to be followed consistently in the API: verbs
nouns
When looking at our Transforms methods as a whole, most tend to use verb names - We even chose one to be named As far as Transforms go, I only see the above two using noun names. Instead of Looking at the other 2 methods in the same class we have: public static class TextLoaderSaverCatalog
{
public static IDataView ReadFromTextFile(this DataLoadSaveOperations catalog, TextLoader.Column[] columns, string path, Action<TextLoader.Arguments> advancedSettings = null);
public static void SaveAsText(this DataLoadSaveOperations catalog, IDataView data, Stream stream, char separator = '\t', bool headerRow = true, bool schema = true, bool keepHidden = false);
public static TextLoader TextReader(this DataLoadSaveOperations catalog, TextLoader.Arguments args, IMultiStreamSource dataSample = null);
public static TextLoader TextReader(this DataLoadSaveOperations catalog, TextLoader.Column[] columns, Action<TextLoader.Arguments> advancedSettings = null, IMultiStreamSource dataSample = null);
} 2 verbs and one noun. Now, if we include the learners (or anything deriving from verb
But everything inside of
We could consider In summary, I agree with @CESARDELATORRE that the method |
I'd certainly like the names to be reconciled. In a case as @eerhardt points out where everything would get a prefix like Regarding the specific name of the main thing that sparked the larger discussion, IIRC, was there not feedback from .NET team that the phrase |
I wanted to point out another naming problem regarding MLContext extensions: Extensions to MLContext don't consistently match either the static API names, or the dynamic API names for estimators. This leads users that directly instantiate the dynamic API to find different names for the same estimators than when finding them through MLContext. Since the estimators obtained through MLContext use the dynamic API, I would suggest that their names match the dynamic API names. |
In the API design review meeting today we decided to add a |
Great, we have concrete action item. Removing myself and 'need-info' |
|
Reopening this issue. Not critical, but still feels non consistent with the returned type. TextLoader textLoader = mlContext.Data.CreateTextReader(new TextLoader.Arguments() Why is it not aligned to the type which is "Loader"? I think it should be "CreateTextLoader" (instead of CreateTextReader) since it is returning a TextLoader object type, right? The other way around would be to rename the "TextLoader" type to "TextReader", but being consistent on naming between types and methods. |
@CESARDELATORRE You are right - I missed the Loader/Reader part. I'll send a PR for this. |
Since the object being created is a "TextLoader", I'd recommend the method's name to say so, instead of "TextReader" which looks like a different type.
I mean code like the following feels confusing:
In addition to that, methods should have a verb as part of the name, so if what it is doing is to create a TextReader, let's say so, as:
mlContext.Data.CreateTextLoader()
We're not being consistent now when having some methods with a verb but other methods just a noun:
It is also against C# conventions (and most languages). A method's name should have a verb describing the action being performed by that method:
https://docs.microsoft.com/en-us/dotnet/standard/design-guidelines/names-of-type-members#names-of-methods
The text was updated successfully, but these errors were encountered: