Skip to content

Instantly share code, notes, and snippets.

@dadarek
Created August 20, 2013 16:23
Show Gist options
  • Save dadarek/6283752 to your computer and use it in GitHub Desktop.
Save dadarek/6283752 to your computer and use it in GitHub Desktop.
Command-Query Violation
class SomeClass{
private int reason;
public bool Go(){
int value = SomeBigCalculation();
if( value > 5 ){
this.reason = "Too Big";
return true;
}
return false;
}
}
class SomeClass{
private int reason;
public bool IsTooBig(){
int value = SomeBigCalculation();
return value > 5;
}
public void SetReason(){
this.reason = "Too Big";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment