Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Personally, I consider the idiom of a plain-old-data-struct to be vastly underrated. Mutable structs which encapsulate state in anything other than public fields are problematic, but sometimes it's useful to bind together a fixed collection of variables stuck together with duct tape so they can be passed around as a unit. A plain-old-data-struct is a perfect fit for that usage; it behaves like a fixed collection of variables stuck together with duct tape, since that's what it <em>is</em>. One can with some work come up with an immutable class which requires slow and hard-to-read code to do anything with, or with some more work come up with something that's still slow but not quite so unaesthetic; one can also code structures in such fashion as to mimic such classes. In many cases, however, the only effect of going through all that effort is that one's code will be slower and less clear than it would have been if one had simply used a PODS.</p> <p>The key thing that needs to be understood is that a PODS like <code>struct PersonInfo { public string Name, SSN; public Date Birthdate; }</code> does <em>not</em> represent a person. It represents a space that can hold two strings and a date. If one says <code>var fredSmithInfo = myDatabase.GetPersonInfo("Fred Smith");</code>, then <code>FredSmithInfo.BirthDate</code> doesn't represent Fred Smith's birthdate; it represents a variable of type <code>Date</code> which is initially loaded with the value returned by a call to <code>GetPersonInfo</code>--but like any other variable of type <code>Date</code>, could be changed to hold any other date.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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