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

Rename Poll::Question::Answer to Poll::Question::Option #5537

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

javierm
Copy link
Member

@javierm javierm commented May 13, 2024

Objectives

  • Make it possible to remember what the Poll::Answer class does
  • Make it easier to add an association between poll question options and poll answers

Release notes

⚠️ In order to try to help developers to avoid losing their sanity, we've renamed the Poll::Question::Answer model to Poll::Question::Option. If you've got some custom codes dealing with polls, you might have to update it. For now, we are not renaming the related database tables in order to make the upgrade easier.

We were using three different variable names for the same thing, in
consecutite tests.
Not sure about when we stopped needing them, but all usages of
require_dependency definitely become obsolete after we started using
Zeitwerk in commit 5f24ee9.

We're also going to rename `Poll::Question::Answer` to
`Poll::Question::Option`, so the conflict of having two `Answer`
classes, that made us add this code in the first place, will not even
exist.
We added the code indicating the table in commit 673ec07 because back
then we had a `title` column in both the `poll_question_answers` table
and the `poll_question_answer_translations` table.

Since that's no longer the case since commit 7a78776, we can simplify
the code.
Just like we do every else (even on that very same file), we use the
method instead of the instance variable.
Having a class named `Poll::Question::Answer` and another class named
`Poll::Answer` was so confusing that no developer working on the project
has ever been capable of remembering which is which for more than a few
seconds.

Furthermore, we're planning to add open answers to polls, and we might
add a reference from the `poll_answers` table to the
`poll_question_answers` table to property differentiate between open
answers and closed answers. Having yet another thing named answer would
be more than what our brains can handle (we know it because we did this
once in a prototype).

So we're renaming `Poll::Question::Answer` to `Poll::Question::Option`.
Hopefully that'll make it easier to remember. The name is also (more or
less) consistent with the `Legislation::QuestionOption` class, which is
similar.

We aren't changing the table or columns names for now in order to avoid
possible issues when upgrading (old code running with the new database
tables/columns after running the migrations but before deployment has
finished, for instance). We might do it in the future.

At first I tried not to change the internationalization keys either so
existing translations would still be valid. However, since we have to
change the keys in `activerecord.yml`, since it uses class names and
we're changing the class names, we're changing them everywhere for
consistency.

Note that it isn't clear whether we should use `option` or
`question_option` in some cases. In order to keep things simple, we're
using `option` where we were using `answer` and `question_option` where
we were using `question_answer`.
@javierm javierm force-pushed the rename_question_answer_to_option branch from a4779f5 to 3284871 Compare May 17, 2024 20:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Consul Democracy
  
Reviewing
Development

Successfully merging this pull request may close these issues.

None yet

1 participant