Skip to content

Instantly share code, notes, and snippets.

@nasrabadiAM
Created January 27, 2019 19:27
Show Gist options
  • Save nasrabadiAM/cf47047874f696f9b95d2c1131fffead to your computer and use it in GitHub Desktop.
Save nasrabadiAM/cf47047874f696f9b95d2c1131fffead to your computer and use it in GitHub Desktop.
Fix Single Responsibility Principle
class Text {
String text;
String author;
int length;
String getText() { ... }
void setText(String s) { ... }
String getAuthor() { ... }
void setAuthor(String s) { ... }
int getLength() { ... }
void setLength(int k) { ... }
/*methods that change the text*/
void allLettersToUpperCase() { ... }
void findSubTextAndDelete(String s) { ... }
}
class Printer {
Text text;
Printer(Text t) {
this.text = t;
}
void printText() { ... }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment