#Personal-finance app dividing into class

1 messages · Page 1 of 1 (latest)

dense forum
#

Hi! Like most people starting out with coding, I've made a code of a finance-app in one single file. Now, I'm trying to devide my code in MyAccount.java to a second class CSVHandler.java, but I am encountering some errors. How can I best face this, and do you have any tips when you're at that stage where you have ~360 lines of code and want to divide it into maybe some classes? I really appreciate the help and if it would be easier to go over it together in a vc I would be down for that too! Thank you!

opal forgeBOT
#

<@&987246399047479336> please have a look, thanks.

proud needle
#

You'll get more people looking at it if you just drop the java sourcefile(s) here instead of a zip. The bot will upload it as a 'gist'.

waxen hill
#

ive dl it it is 400 lines long

proud needle
#

If you drop the file here it'll get uploaded. You won't be able to paste it into a post.

#

@dense forum what problems are you having. You mentioned errors - what kind of errors?

#

I expect you might want to break it into

  • Transaction - a data-model class that represents a single transaction (instead of a LinkedHashMap)
  • Account - a data-model class that allows deposits and withdrawals and answers questions about the balance and the history of transactions (this could still use a LinkedHashMap<String, Transaction>. This could have a saveToCsv(Path) and a factory method to yield an account from a CSV.
  • PersonalFinance - The commandline UI of the application, holding a currently loaded account and having the application entry point (the main method).
lethal schooner
#

Use MVC design pattern

dense forum
tight lodge
#

model-view-controller

#

a way to organize ur code

#

splitting data/model, the view/display/ui and the logic/controller from each other

#

a technique that allows u to creates flexible and modular code

#

where u also can easily swap out parts against others

#

for example introduce a new ui system without having to touch most of the code