Timeline for Code quality: expressiveness vs. conciseness
Current License: CC BY-SA 4.0
10 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Jan 9, 2024 at 16:58 | comment | added | Doc Brown |
... or this: if(lastLoginDay == lastDay - with an explaining variable leftRewardedDays = lastDay-lastLoginDay; the test If(leftRewardedDays<0) becomes self-explanatory. That should be the way to go to make the comments superfluous.
|
|
| Jan 9, 2024 at 16:53 | comment | added | Doc Brown |
"Rather than these comments, I would prefer to see the part of a requirements document that talks about eligibility for a reward.", having such spec alone does not bring much benefit when the code isn't easily mapped to the spec. I think it would be more beneficial when the terms, variable names and function names in the code would match what is currently written in the comments - then we can ditch the comments. For example, when _progressStore.level means some kind of user level, why isn't there a method Userlevel(){return _progressStore.level;}` which makes this clear?
|
|
| Jan 9, 2024 at 9:13 | comment | added | Sir Falk | Also, comparing the 4 variants, I should have maybe mentioned that there is no documentation except for the code (not my choice), and no requirements document. Requirements are basically done "on the fly". While, as already mentioned, your criticism is very much valid, this question was supposed to be more about the style that you should choose generally (expressiveness vs. conciseness). Do you have any thoughts on that? | |
| Jan 9, 2024 at 9:08 | comment | added | Sir Falk |
Thank you for your comment, this is very helpful! They way I understand this, there are 2 main criticisms: 1. Going into pre- / post-conditions and invariants. Do I understand this correctly, that you would prefer more comments on the function input and output variables, for example acceptable ranges or the nature of variables like the units etc? 2. Better naming in a way that promotes more “natural” reading of the code, more like an English text, f.e.renaming the function title or using helper functions like isEligibleCustomer. Is that correct?
|
|
| Jan 8, 2024 at 21:04 | comment | added | J_H | @DocBrown Yeah. Guess I didn't want to keep flogging same horse as I continued to read the next three. I focused on the first because OP held it up as the gold standard, an improvement over the others, and I wanted to show that there's still room to improve. | |
| Jan 8, 2024 at 21:03 | history | edited | J_H | CC BY-SA 4.0 |
added 6 characters in body
|
| Jan 8, 2024 at 20:53 | comment | added | Doc Brown | Good answer. However, you wrote "Variant1 is not terrific." - why do you refer here only to Variant1? AFAIKS all four variants have the same contract issue. | |
| Jan 8, 2024 at 20:47 | history | edited | J_H | CC BY-SA 4.0 |
added 257 characters in body
|
| Jan 8, 2024 at 20:17 | history | edited | J_H | CC BY-SA 4.0 |
added 5 characters in body
|
| Jan 8, 2024 at 20:12 | history | answered | J_H | CC BY-SA 4.0 |