Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
In the class diagram shown in Figure 7.1, the Bill class has a bidirectional relationship to the AuditFacade class. This design has two fundamental flaws. The Bill is tightly coupled to the concrete AuditFacade class, and the relationship is bidirectional. Bad all around! This can be seen in Listing 7.3, illustrating the Bill class’s audit method.
Listing 7.3. Audit Method of the Bill Class
public void audit() {
AuditFacade auditor = new AuditFacade();
this.billData.setAuditedAmount(auditor.audit(this));
this.persist();
}
Notice that the audit method actually creates the AuditFacade, calls the audit method, and passes a reference to Bill. Ugly. Let’s clean this up a little bit. Although there are obvious technology reasons why we need to clean this up, there is also a motivating business force.