Skip to content

Instantly share code, notes, and snippets.

@mgroves
Created January 22, 2014 01:45
Show Gist options
  • Select an option

  • Save mgroves/8552108 to your computer and use it in GitHub Desktop.

Select an option

Save mgroves/8552108 to your computer and use it in GitHub Desktop.
// which is the better design, given StateArgs? A or B?
public class StateArgs
{
public bool IsValid { get; set; }
public string Value { get; set; }
}
// A
public static void ValidateState(StateArgs args)
{
if(string.IsNullOrEmpty(args.Value))
return;
args.IsValid = Dictionary.Contains(args.Value);
}
// B
public static void ValidateState(StateArgs args)
{
if(string.IsNullOrEmpty(args.Value))
args.IsValid = false;
else
args.IsValid = Dictionary.Contains(args.Value);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment