refactor: Files feedback_message without NULL state#3046
refactor: Files feedback_message without NULL state#3046arkirchner wants to merge 1 commit intomainfrom
Conversation
| RSpec.describe CodeOcean::File do | ||
| let(:file) { described_class.create.tap {|file| file.update(content: nil, hidden: nil, read_only: nil) } } | ||
| let(:file) do | ||
| described_class.new.tap do |file| |
There was a problem hiding this comment.
I want to make clear that the create does not create a record here. Therefore, I use assignment and call validate.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3046 +/- ##
=======================================
Coverage 70.08% 70.09%
=======================================
Files 215 215
Lines 6850 6851 +1
=======================================
+ Hits 4801 4802 +1
Misses 2049 2049 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
b9620fe to
67b20ec
Compare
Column type string should not have a null state to avoid logical distinction between NULL and '' case. User defined tests are created without feedback_message. Removing the NULL case allows the new record to render the empty feedback_message. An edge case is resolved when a test for assessment with a feedback_message is transformed to a user defined test. The feedback_message is overwritten, and no validation error for invisible fields is displayed. Resolves #3014
67b20ec to
456128c
Compare
|
would adding a spec to test for the bug in #3014 be an option? |
MrSerth
left a comment
There was a problem hiding this comment.
I am not happy to set a blank string as a solution here. This adds further custom code (like a custom validation rather than using a built-in validation), makes analysis of the code files more difficult, and potentially increases data storage requirements.
Which other solutions to the problem did you consider? Why did you decide that way?
|
If a column can be Thoughtbot includes this in their excellent developing guides. There is also a very famous blog post on the NULL state that explains the ideas on a higher level. These blog posts on the matter are also superb: A good Rails application as an example of this implementation is Mastodon. While this is not a standard that is adopted by everyone I am a big fan. This data normalization avoids conditional logic and makes the code more readable. |
|
Thanks for detailing your thoughts.
I disagree. Only
This is a statement about a view, not about persistency. I see a logical differentiation between both, and an arguably "easier" access method should not influence the data modeling.
After reading these blog posts, I think only two of them actually address
After careful considerations and some discussions with experienced engineers, my mind hasn't changed: Data modeling in the database should be based on the business logic, and not follow an easier access pattern for the views. Also, I want to note that we could strive for two kinds of values here, too: a present, not empty string for teacher-defined assessments and |
What is the business case that requires differentiation between NULL and "". After carefully checking the code, I was unable to find one. |
|
Since there are fundamental differences between our views of what good software design is I will close this PR. I will check for the I have avoided this solution because it adds further variants to code that could have been avoided by data normalization. |
So far, we don't need/require
Thank you for considering that; I'll expect a rather simple change to avoid the bug in question. Also, I am open to hearing other opinions, so in case you want to ask the team to have another look and share their perspectives, you are more than welcome to.
I am much in favor of data normalization. What about adding a migration to convert all empty strings |
Column type string should not have a null state to avoid logical
distinction between
NULLand''case.User defined tests are created without feedback_message. Removing
the NULL case allows the new record to render the empty feedback_message.
An edge case is resolved when a test for assessment with a feedback_message
is transformed to a user defined test. The feedback_message is
overwritten, and no validation error for invisible fields is displayed.
Resolves #3014