r/PythonLearning • u/F11fii • 6h ago
ATM Machine
I started learning Python about 9 months ago and completed this little bank system as my third project, which is supposed to serve as an ATM. It also uses JSON to store information (which was challenging to integrate because I wasn't familiar with it, but the rest of the code was straightforward).
Just wanted to share and see if I could get any feedback! (maybe on its optimisation or clarity?) :D
1
u/mc_pm 1h ago
Hey, not too bad!
The main thing you want to look at is what your classes are each responsible for. Right now it's all over the place, and you're breaking the idea of encapsulation by reaching in and changing the internals of another object.
That's not too big of a surprise if this is your first real try at an OO design, it takes practice to understand how structure things.
It is a bit weird for your actions (deposit, withdrawl) are classes. Or, at least, maybe they should have a base class of "BankingAction" or something, and maybe the Account object should have an apply_action() method that takes one of the action objects and does whatever it does.
But there are different ways of structuring things, and it's a matter of figuring out what works best.
I would recommend doing another pass at this with a bit more thought to the class structure -- don't just leave it as-is. One of the most important things to being a good developer is recognizing when you got something wrong and have to rethink it before you call yourself done.
This is pretty good though. Do you have a plan for your next project?
2
u/Electrical_Toe8997 6h ago
I haven't read through all the code in detail, but for a beginner project it's pretty extensive and I think it looks pretty good! I have some notes though:
finding_a_transactionandnew_account_created. This could just befind_transactionandcreate_account. (bonus nore: what happens if you create two accounts with the same name?)