
Clean code should read well-written prose - Robert MartinAs a rule, there is a pronounced correlation between bad code and code that is full of comments. Comments are the most characteristic feature of erratic source code.
//
List<Employee> find(Status status) {
...
}
find , , , . , find , , . «»? ? ? « », – , .List<Employee> getEmployeesByStatus(Status status) {
...
}//
void sendEmail() {
...
}
//
public class Employee {
...
}
/**
* @param title CD
* @param author CD
* @param tracks CD
*/
public void addCd(String title, String author, int tracks) {
...
}// , ,
// -, , ,
// -
public void doSomeThings() {
//
...
...
...
// -
...
...
...
// ,
...
...
...
// -
...
...
...
}
public void sendPromotionEmailToUsers() {
calculatePrices();
compareCalculatedPricesWithSalesPromotions();
checkIfCalculatedPricesAreValid();
sendPromotionEmail();
}
sendPromotionEmailToUsers(). , ./*
public void oldFunction() {
noOneRemembersWhyIAmHere();
tryToUnCommentMe();
iWillProbablyCauseABuildFailure();
haHaHa();
}
*/, – , , . —
public class User {
...
//
String name;
...
}name firstName lastName.//
void processEmployees() {
...
List<Employee> employees = findEmployees(statusList);
...
}
//
List<Employee> findEmployees(List<String> statusList) {
...
}//
void processEmployees() {
...
List<Employee> employees = findEmployees(statusList);
...
}
//
List<Employee> findEmployees(List<String> statusList) {
...
}//
void processEmployees() {
...
List<Employee> employees = findEmployees(statusList);
...
}
//
List<Employee> findEmployees(List<String> nameList) {
...
}processEmployees , . ?void processEmployees() {
...
List<Employee> employees = findEmployeesByName(nameList);
...
}
List<Employee> findEmployeesByName(List<Name> nameList) {
...
}// kk:mm:ss EEE, MMM dd, yyy
Pattern timePattern = Pattern.compile("\\d*:\\d*:\\d* \\w*, \\w*, \\d*, \\d*");Source: https://habr.com/ru/post/458990/
All Articles