-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
NF: rename model to note type #17598
base: main
Are you sure you want to change the base?
Conversation
As David mentioned recently, Anki don't use "model" anymore, it should not be in the codebase. There are two places where `model` should not be replaced. When the variable refers to a model that is not a note type (e.g. a viewModel, the Card Browser's model..). And when the word "model" appears in the API. Indeed we should not break the existing code using the API. While it may be considered to extend our API, duplicating the Model commands to introduce a NoteType command with the same meaning. And, maybe one day, deprecate the previous API. But I don't think there is even a need to deprecate the API, it does not really lead to confusion. On top of replacing "model", "models", "Model", "Models", "MODEL", "MODELS", we also rename the variables "m", "m2" and "mm" as those variable where abbreviations for "Model". I renamed some layout, menu, In one case, the documentation was wrong. It mentioned "model" instead of "template". I thus replaced "model" by "template" in order to correct the documentation. Note that all the changes were done manually. I used Android-Studio to rename function, variables, values and constant. But I generally avoided the "search and replace" feature which may have led to erroneous update. (Example of exception: `m` and `mm` in `modelTest`
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 is a huge change, could it be broken down to PRs in the ~300LOC level, so it's reasonable to review in a sitting?
- This contains breaking changes to our API
- Note: Renaming parameters in Kotlin is a breaking change
- Renaming an activity is a breaking change to our public API
addNoteUsingBasicModel
might as well beaddBasicNote
NoteTypeType
is not a good name
@@ -199,7 +199,7 @@ class ModelFieldEditor : | |||
} | |||
} | |||
c.setConfirm(confirm) | |||
this@ModelFieldEditor.showDialogFragment(c) | |||
this@NoteTypeFieldEditor.showDialogFragment(c) |
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 believe the @
shouldn't be necessary at all
@Suppress("SameParameterValue") front: String, | ||
@Suppress("SameParameterValue") back: String, | ||
): Note = addNoteUsingModelName("Basic (type in the answer)", front, back) | ||
): Note = addNoteUsingNoteTypeName("Basic (type in the answer)", front, back) |
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.
addNoteOfType
would seem sensible
As David mentioned recently, Anki don't use "model" anymore, it should not be in the codebase.
There are two places where
model
should not be replaced. When the variable refers to a model that is not a note type (e.g. a viewModel, the Card Browser's model..). And when the word "model" appears in the API. Indeed we should not break the existing code using the API.While it may be considered to extend our API, duplicating the Model commands to introduce a NoteType command with the same meaning. And, maybe one day, deprecate the previous API. But I don't think there is even a need to deprecate the API, it does not really lead to confusion.
On top of replacing "model", "models", "Model", "Models", "MODEL", "MODELS", we also rename the variables "m", "m2" and "mm" as those variable where abbreviations for "Model". I renamed some layout, menu,
In one case, the documentation was wrong. It mentioned "model" instead of "template". I thus replaced "model" by "template" in order to correct the documentation.
Note that all the changes were done manually. I used Android-Studio to rename function, variables, values and constant. But I generally avoided the "search and replace" feature which may have led to erroneous update. (Example of exception:
m
andmm
inmodelTest