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

NF: rename model to note type #17598

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Arthur-Milchior
Copy link
Member

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

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`
Copy link
Member

@david-allison david-allison left a 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 be addBasicNote
  • NoteTypeType is not a good name

@@ -199,7 +199,7 @@ class ModelFieldEditor :
}
}
c.setConfirm(confirm)
this@ModelFieldEditor.showDialogFragment(c)
this@NoteTypeFieldEditor.showDialogFragment(c)
Copy link
Member

@david-allison david-allison Dec 14, 2024

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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

addNoteOfType would seem sensible

@lukstbit lukstbit added the Needs Author Reply Waiting for a reply from the original author label Dec 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Has Conflicts Needs Author Reply Waiting for a reply from the original author
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants