r/javahelp • u/Interesting-Hat-7570 • Jun 17 '24
Java
Hello everyone, I'm new to Java. I would like to improve my analysis and design skills. I've recently started creating my own projects. Recently, I wrote a Battleship game. https://github.com/LetMeDiie/Battleship. I would like to know from you how poorly structured my architecture is. I've added comments to all classes and included a README folder, although it was supposed to describe the application architecture, but I didn't quite finish it.
3
u/Dense_Age_1795 Jun 17 '24
the only error that i saw in your code is to not add a base package, for the rest is pretty nice, the only thing that i miss is some unit tests
1
u/Interesting-Hat-7570 Jun 17 '24
Thank you for your time. I'm glad to hear something good about my code. Yes, sorry, I haven't learned how to test yet. I'll add it when I learn. Could you clarify what a base package is? It's the first time I've heard of it.
1
u/Dense_Age_1795 Jun 17 '24
basically a group of directories that define the classpath, this is done for avoiding name collision, this is really simple just create some directories inside your src directory like com/username/projectname and then move all your packages to that directory, intellij will do the refactor for you
1
u/Interesting-Hat-7570 Jun 18 '24
Thanks again for your advice.
I will take note of this and hopefully apply it in the future.
3
u/Poseidon_22 Jun 17 '24
From what I’ve read, I have not seen any bad practices or questionable choices. It was easy to read through the files & get an idea of how each part works. Project files are nicely structured and each class has its own separate purpose.
I think the place of the most complexity is Game class, which is to be expected. Here input is directly retrieved and parsed. Generally this is discouraged (see ‘Controller’ in GRASP principle). For a small project it’s not an issue of course. If you would expand your project, I’m very sure Game will become very complex to delegate input correctly.
But again, adding another layer for input would not be necessary here. For a beginner it looks very good, but I don’t think you are a beginner in OOP (:
2
u/Interesting-Hat-7570 Jun 18 '24
Oh my goodness, how nice to hear that.
This is my third project.
The first 2 turned out very bad.
But I posted every project and asked experienced people for advice. Most likely, yes, this is not only my merit.
2
u/Interesting-Hat-7570 Jun 18 '24
Thanks for your advice. I'll take note of this and hope to find a use for it in the future.
•
u/AutoModerator Jun 17 '24
Please ensure that:
Your code is properly formatted as code block - see the sidebar (About on mobile) for instructions
You include any and all error messages in full
You ask clear questions
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.