Note that there are some explanatory texts on larger screens.

plurals
  1. USJustin Doyle
    primarykey
    data
    text
    plurals
    1. This table or related slice is empty.
    1. CO@jalf, perhaps I'm not explaining myself well enough. I'm not suggesting making a _Black_ singleton. I'm suggesting making _Colors_ a singleton. As in a canonical list of colors that will always be the same! I don't want to set text to Colors.Black and end up with red text. Colors is accessible anywhere in your code, hell, anywhere in _anyone's_ code if you include the reference. System.Environment.Newline is also accessible to _every_ part of your code. It doesn't matter though because it's not a variable.
      singulars
    2. COOn testing, of course you wouldn't want it pulling from the production database, but it would be easy to change the connection so the data that the singleton is pulling during your tests is from a test database or a mock object. See the question above.
      singulars
    3. COjalf, what I'm talking about is the equivalent of a global constant, not a global variable. Since the objects are immutable there's no need to get a 'clean' instance. Something akin to Colors.x maybe. Yes you can make another list of Colors that's identical to Colors if you want but it's not 'Colors'. You can make a copy of the table but it's not the table. Colors is also globally available, is that a problem? 1) I'm talking specifically about reference lists. 2) sometimes particular lists are global to the domain of the application. Do you need separate lists of all the states?
      singulars
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload