Skip to content

Instantly share code, notes, and snippets.

@caleb-vear
Created February 19, 2011 11:35
Show Gist options
  • Select an option

  • Save caleb-vear/835014 to your computer and use it in GitHub Desktop.

Select an option

Save caleb-vear/835014 to your computer and use it in GitHub Desktop.
Put your behaviour where it belongs
// This could just as easily be a command handler in a view model
private void AcceptButton_Clicked(object sender, EventArgs e)
{
if (CurrentNetWeight <= 0)
throw new Exception("Can not accept weights that <= 0");
Load.GrossWeight = GrossWeight;
Load.TareWeight = TareWeight;
Load.NetWeight = CurrentNetWeight;
Load.WeightAcceptedTime = DateTime.Now;
}
// This could just as easily be a command handler in a view model
privte void AcceptButton_Clicked(object sender, EventArgs e)
{
// Much better the behaviour and checks related to accepting a weight
// Can go where they belong now
Load.AcceptWeights(GrossWeight, TareWeight);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment