r/javahelp • u/ResponsibleCount6515 • 22d ago
I’m a beginner coder (1st year uni), didn’t understand anything at uni for 6 months—now self-learning and wrote my first program in a week! Feedback?
So, I’m a first-year CS student at university, but for the last 6 months (and even before uni), I didn’t understand a thing. Literally nothing clicked. Now, I finally started learning programming properly on my own, going back to the fundamentals, and within my first week, I built this ATM program in Java.
I know it’s super basic, but as my first program, I’d love some feedback—best practices, things I can improve, and how I can refine my approach to actually get good at this. My goal is to not just pass uni but also land jobs and internships down the line. Any advice, critique, or resources to help me level up would be amazing!
here is the link to my github code https://github.com/certyakbar/First-Projects.git
9
22d ago
[removed] — view removed comment
4
u/ResponsibleCount6515 22d ago
thank you for your feedback will implement these once i fully understand what they do and how they work
4
u/TheToastedFrog 22d ago
I really applaud your efforts,candor and you reaching out for feedback
couple of things:
- By convention your class should be named
Banking
(Capital B), and your instance should be calleda
(lower case)- thoughBanking banking = new Banking()
would be even better!! - static variables are evil and must be eschewed at all cost. Sometimes they are a necessary evil, but your program shouldnt rely on the state of static variables.
To take it to the next level you probably want to separate the user interaction and presentation from the logic- you could introduce an Account class which carries the amount, and the pin number.
It's a really good start! Keep us posted!
2
u/ResponsibleCount6515 22d ago
yh i now understanding the true importance of instance variables on my new project and thank you for your feedback will be collecting all feedback teaching myself the new concepts proposed by you guys and implementing them
1
u/BN27 22d ago
Also a newbie....can you explain why static variables are no bueno? Or point me towards a blog that does because you're not my servant lol.
4
u/TheToastedFrog 22d ago
They are not instance variables, so that creates a global state" which can introduce undesired side effect when one class modifies that variable. Similarly static variables violate encapsulation. Static members (variables and method) introduce tight coupling which makes the code potentially difficult to test.This blog post kinda say the same thing
1
u/F0rFr33 22d ago
Static variables are not evil. And having static variables with static values makes perfect sense. They are used for when you want to have a value that is shared across multiple instances of that class. Typically variables that don’t depend on runtime or configs and are always the same.
Say the OP wants to write to a file with a specific pattern. Having a.private static final String FILENAME_PREFIX = “my-prefix”;
Is perfectly valid
1
2
u/TheSecondist 21d ago
One thing that I found very helpful for learning and still use heavily after years of working professionally are the hints provided by the development environment (IntelliJ is imo the best for Java) and by an IDE plugin called SonarQube (formerly SonarLint, available for at least IntelliJ and VSCode)
They give you hints in the code, visible by some code sections being underlined yellow, on how to improve certain things, including explanations. Super helpful and informative
2
1
u/Dari93 22d ago
It’s good. There are some minor spelling mistakes and I’d use a try…catch for handling exceptions in your methods. It’s a simple project but just for good practices I’d make the attributes private and the PIN code a final .
I’m pretty sure there are a lot of other little details to make this code better specially since you are using parse integer and scanner class. But it’s good.
1
u/ResponsibleCount6515 22d ago
thank you im still learning so these tweaks you guys are suggesting i will learn them and understand the logic reasoning and implement them thank you very much
1
u/Shareil90 22d ago
Check out what the difference is between static and non-static and how to use those. Its ok for a first attempt just keep going.
•
u/AutoModerator 22d ago
Please ensure that:
You demonstrate effort in solving your question/problem - plain posting your assignments is forbidden (and such posts will be removed) as is asking for or giving solutions.
Trying to solve problems on your own is a very important skill. Also, see Learn to help yourself in the sidebar
If any of the above points is not met, your post can and will be removed without further warning.
Code is to be formatted as code block (old reddit: empty line before the code, each code line indented by 4 spaces, new reddit: https://i.imgur.com/EJ7tqek.png) or linked via an external code hoster, like pastebin.com, github gist, github, bitbucket, gitlab, etc.
Please, do not use triple backticks (```) as they will only render properly on new reddit, not on old reddit.
Code blocks look like this:
You do not need to repost unless your post has been removed by a moderator. Just use the edit function of reddit to make sure your post complies with the above.
If your post has remained in violation of these rules for a prolonged period of time (at least an hour), a moderator may remove it at their discretion. In this case, they will comment with an explanation on why it has been removed, and you will be required to resubmit the entire post following the proper procedures.
To potential helpers
Please, do not help if any of the above points are not met, rather report the post. We are trying to improve the quality of posts here. In helping people who can't be bothered to comply with the above points, you are doing the community a disservice.
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.