title: Data into classes, timing, procedure
body: <p>I have a style/good code question. It's one of those "not that important because it's working" things but still, I'd like some insight from the community. I'm in C# but the methodology could apply to anything OOP</p>
  
  <p>So I have a class, it's essentially a container for data. I pass the class to the database instead of passing 10 parameters. The database writing class drops each data member into it's respective SQL parameter and executes the stored procedure in my database.</p>
  
  <p>My question is, when I am collecting data into the class I have all of them attached to Change events. Like</p>
  
  <pre><code>private void chkIce_CheckedChanged(object sender, EventArgs e)
      {
          CheckBox chk = (CheckBox)sender;
  
          if (chk.CheckState == CheckState.Checked)
              outTruck.setWeather(2, true);
          else
              outTruck.setWeather(2, false);
  
      }
  </code></pre>
  
  <p>and</p>
  
  <pre><code>    private void txtTrailer_TextChanged(object sender, EventArgs e)
      {
          TextBox txt = (TextBox)sender;
          newRecord.TrailerNumber = txt.Text.ToString();
      }
  </code></pre>
  
  <p>This goes in and sets the ice value of my class to true/false based on what the user selects. Or sets the text. It's pretty straightforward, but there is a bit of code overhead as in each control has it's own event (also the cast on sender line might be overkill). The other way would be to collect all the data at submit. Drop it all into the class then. There was something else called entity framework and ORM, but I am at the moment stuck in .NET 3.5(we are with the times) and I've read that does not apply until you get to 4.0. I've not really read if there is a standard, it seems to be more preference than anything. So, fellow stack overlowieans...what are your thoughts? </p>