Timeline for Is a new Boolean field better than a null reference when a value can be meaningfully absent?
Current License: CC BY-SA 4.0
26 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Mar 3, 2019 at 3:01 | history | tweeted | twitter.com/StackSoftEng/status/1102041259626151936 | ||
Mar 3, 2019 at 1:25 | audit | First posts | |||
Mar 4, 2019 at 1:59 | |||||
Mar 1, 2019 at 7:59 | vote | accept | ocomfd | ||
Feb 28, 2019 at 16:04 | history | became hot network question | |||
Feb 28, 2019 at 12:57 | comment | added | Hagen von Eitzen | Problems might occur when you need to distinguish between "the state of X is not known" and "X is known not to exist". But that seems not to apply to your use case | |
Feb 28, 2019 at 8:30 | comment | added | Eric Lippert | Are you familiar with the null object pattern? | |
Feb 28, 2019 at 5:16 | history | edited | ocomfd | CC BY-SA 4.0 |
added 199 characters in body
|
Feb 27, 2019 at 23:00 | history | unprotected | Mason Wheeler | ||
Feb 27, 2019 at 16:15 | answer | added | ANone | timeline score: 1 | |
Feb 27, 2019 at 16:06 | comment | added | J. Doe | I would use an enum with 3 cases for this :) | |
S Feb 27, 2019 at 15:32 | history | suggested | Peter Mortensen | CC BY-SA 4.0 |
Copy edited (e.g. ref. <https://en.wiktionary.org/wiki/Boolean#Adjective>).
|
Feb 27, 2019 at 11:39 | answer | added | jmoreno | timeline score: 2 | |
Feb 27, 2019 at 10:33 | review | Suggested edits | |||
S Feb 27, 2019 at 15:32 | |||||
Feb 27, 2019 at 9:30 | comment | added | Christian Hackl |
@FrankHopkins: An example would be languages where variables can be left uninitialised, e.g. C or C++. lastChangePasswordTime may be an uninitialised pointer there, and comparing it to anything would be undefined behaviour. Not a really compelling reason not to initialise the pointer to NULL / nullptr instead, especially not in modern C++ (where you wouldn't use a pointer at all), but who knows? Another example would be languages without pointers, or with bad support for pointers, maybe. (FORTRAN 77 comes to mind...)
|
|
Feb 27, 2019 at 8:14 | history | protected | gnat | ||
Feb 26, 2019 at 20:17 | comment | added | Frank Hopkins | @ChristianHackl hmm, agree that there are different "perfect" solutions, but i don't see any (major) language though where using a separate boolean would be a better idea in general than doing null/nil checks. Not totally sure about C/C++ as I haven't been active there for quite a while, though. | |
Feb 26, 2019 at 19:10 | comment | added | Kristian H | Is there a reason you wouldn't want the lastChangePasswordTime set to password creation time (creation is a mod, after all)? | |
Feb 26, 2019 at 16:59 | answer | added | Gherman | timeline score: 11 | |
Feb 26, 2019 at 16:22 | answer | added | Joel | timeline score: 4 | |
Feb 26, 2019 at 14:18 | answer | added | Rik D | timeline score: 2 | |
Feb 26, 2019 at 11:15 | review | Close votes | |||
Mar 3, 2019 at 3:05 | |||||
Feb 26, 2019 at 11:09 | answer | added | Tom | timeline score: 65 | |
Feb 26, 2019 at 8:53 | comment | added | Christian Hackl |
This question is quite language-specific, because what constitutes a good solution largely depends on what your programming language offers. For example, in C++17 or Scala, you'd use std::optional or Option . In other languages, you may have to built an appropriate mechanism yourself, or you may actually resort to null or something similar because it's more idiomatic.
|
|
Feb 26, 2019 at 8:50 | answer | added | TZHX | timeline score: 72 | |
Feb 26, 2019 at 8:17 | answer | added | dasmy | timeline score: 29 | |
Feb 26, 2019 at 7:42 | history | asked | ocomfd | CC BY-SA 4.0 |