Skip to main content
added syntax-highlighting
Source Link
Deduplicator
  • 9.3k
  • 5
  • 34
  • 53

Depends on that one line. If the line is readable and concise by itself, the function may not be needed. Simplistic example:

void printNewLine() { System.out.println(); } 
void printNewLine() { System.out.println(); } 

OTOH, if the function gives a good name to a line of code containing e.g. a complex, hard to read expression, it is perfectly justified (to me). Contrived example (broken into multiple lines for readability here):

boolean isTaxPayerEligibleForTaxRefund() { return taxPayer.isFemale() && (taxPayer.getNumberOfChildren() > 2 || (taxPayer.getAge() > 50 && taxPayer.getEmployer().isNonProfit())); } 
boolean isTaxPayerEligibleForTaxRefund() { return taxPayer.isFemale() && (taxPayer.getNumberOfChildren() > 2 || (taxPayer.getAge() > 50 && taxPayer.getEmployer().isNonProfit())); } 

Depends on that one line. If the line is readable and concise by itself, the function may not be needed. Simplistic example:

void printNewLine() { System.out.println(); } 

OTOH, if the function gives a good name to a line of code containing e.g. a complex, hard to read expression, it is perfectly justified (to me). Contrived example (broken into multiple lines for readability here):

boolean isTaxPayerEligibleForTaxRefund() { return taxPayer.isFemale() && (taxPayer.getNumberOfChildren() > 2 || (taxPayer.getAge() > 50 && taxPayer.getEmployer().isNonProfit())); } 

Depends on that one line. If the line is readable and concise by itself, the function may not be needed. Simplistic example:

void printNewLine() { System.out.println(); } 

OTOH, if the function gives a good name to a line of code containing e.g. a complex, hard to read expression, it is perfectly justified (to me). Contrived example (broken into multiple lines for readability here):

boolean isTaxPayerEligibleForTaxRefund() { return taxPayer.isFemale() && (taxPayer.getNumberOfChildren() > 2 || (taxPayer.getAge() > 50 && taxPayer.getEmployer().isNonProfit())); } 
added 9 characters in body
Source Link
Péter Török
  • 46.6k
  • 16
  • 163
  • 185

Depends on that one line. If the line is readable and concise by itself, the function may not be needed. Simplistic example:

void printLineprintNewLine() { System.out.println(); } 

IfOTOH, if the function gives a good name to a line of code containing e.g. a complex, hard to read expression, it is perfectly justified (to me). Contrived example (it is not brokenbroken into multiple lines for readability here):

boolean isEligibleForTaxRefundisTaxPayerEligibleForTaxRefund() { return taxPayer.isFemale() && (taxPayer.getNumberOfChildren() > 2 || (taxPayer.getAge() > 50 && taxPayer.getEmployer().isNonProfit())); } 

Depends on that one line. If the line is readable and concise by itself, the function may not be needed. Simplistic example:

void printLine() { System.out.println(); } 

If the function gives a good name to a line of code containing e.g. a complex, hard to read expression, it is perfectly justified (to me). Contrived example (it is not broken into multiple lines for readability):

boolean isEligibleForTaxRefund() { return taxPayer.isFemale() && (taxPayer.getNumberOfChildren() > 2 || (taxPayer.getAge() > 50 && taxPayer.getEmployer().isNonProfit())); } 

Depends on that one line. If the line is readable and concise by itself, the function may not be needed. Simplistic example:

void printNewLine() { System.out.println(); } 

OTOH, if the function gives a good name to a line of code containing e.g. a complex, hard to read expression, it is perfectly justified (to me). Contrived example (broken into multiple lines for readability here):

boolean isTaxPayerEligibleForTaxRefund() { return taxPayer.isFemale() && (taxPayer.getNumberOfChildren() > 2 || (taxPayer.getAge() > 50 && taxPayer.getEmployer().isNonProfit())); } 
Source Link
Péter Török
  • 46.6k
  • 16
  • 163
  • 185

Depends on that one line. If the line is readable and concise by itself, the function may not be needed. Simplistic example:

void printLine() { System.out.println(); } 

If the function gives a good name to a line of code containing e.g. a complex, hard to read expression, it is perfectly justified (to me). Contrived example (it is not broken into multiple lines for readability):

boolean isEligibleForTaxRefund() { return taxPayer.isFemale() && (taxPayer.getNumberOfChildren() > 2 || (taxPayer.getAge() > 50 && taxPayer.getEmployer().isNonProfit())); }