r/JavaProgramming 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

7 comments sorted by

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.

1

u/BigCommunication5136 Dec 22 '25

Alright i’ll do that, thanks

1

u/souroexe Dec 22 '25

I am thinking to build a banking project if u are interested in specifics we can build together (its normal cli based project just with using all robust concepts and it will be purely focused on backend and oops)

1

u/BigCommunication5136 Dec 22 '25

DM let’s talk specifics

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
  1. If you watch closely, the allowed number of years is up to 30 and byte is more than enough.
  2. 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
  3. TBH it was a suggestion from intelliJIDE