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

            Votes: 0

See more like this: