Creation Method: Loans Exercise
A Class With Too Many Constructors!
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?!?!
(Reading...)
Formatting Hints:
To format... | use this markup: |
---|---|
source code | {source:lang=java|lineNumbers=false}...{source} (Supported languages: java, cpp, csharp, c, python.) |
bold text | __some text__ |
italicized text | ~~some text~~ |
underlined text | @@some text@@ |
a method or class name | ``myMethod(...)`` |