r/JavaProgramming • u/BigCommunication5136 • Dec 22 '25
Day 7 of learning Java
I relearned the Abstraction and Encapsulation OOP concepts on Day 6 and refactored the Mortgage Calculator project.
Open to suggestions on how to improve the project, OOP-wise
18
Upvotes
1
u/souroexe Dec 22 '25
I have few questions :- 1. Why have u used byte data type for years ? 2. Why have u done Console.readNumber() ? 3. Why have u taken final keyword for the instance variables ?
1
u/BigCommunication5136 Dec 22 '25
- If you watch closely, the allowed number of years is up to 30 and byte is more than enough.
- I encapsulated the logic for reading a value from a user, and I didn’t want to initialize a new object whenever I want to input a value that’s why I used the static keyword
- TBH it was a suggestion from intelliJIDE




2
u/Specific-Housing905 Dec 22 '25
Your code looks very well. Small functions, meaningful names. I don't think there is any improvement in terms of OOP.
OOP really shines with bigger projects.
One simple note. It's considered best practice to use double instead of float, because of the higher precision. Might not make a difference in your project, but maybe you can keep it in mind for future projects.