Album Cover

Design Patterns Vol. 1 Java

Close Preview
The above class comes from the financial domain and is based on a system that calculates capital for Loans. The Loan class can represent one of three kinds of loans:
  • Term Loan : A loan for a given period of time that matures on a maturity date
  • Revolver : A "revolving credit" loan that expires on an expiry date
  • RCTL: A Revolving-Credit, Term Loan. It begins life as a Revolver and then converts into a Term Loan.
Loan uses many constructors to allow clients to instantiate the different kinds of loans. Unfortunately, you have to look very closely at the constructors to understand which one to call for a given kind of loan. That's poor design.
You're darned right that is poor design! Why not have subclasses for the three kinds of loans?!?!
| Tweet...
Page rating: | Rate this Page