A private static
modifier on a method is often a symptom of misplaced method that clearly should belong to a different java class:
class OverdraftNoticeMailer { public void sendNotices() { for (Account account : accounts) { if (isOverdrawn(account)) { ... } } } private static boolean isOverdrawn(Account account) { return account.balance().compareTo(BigDecimal.ZERO) < 0; } }
class OverdraftNoticeMailer { public void sendNotices() { for (Account account : accounts) { if (account.isOverdrawn()) { ... } } } } class Account { public boolean isOverdrawn() { return balance.compareTo(BigDecimal.ZERO) < 0; } }
W. Gdela
Discuss Downvote Upvote Votes: 0