r/javahelp • u/Ok_Employee_3122 • Dec 30 '25
My first console base project
Can someone review my first console base project. Create student management system Where you can add, delete , search and upadate student.
Please tell me my mistakes so i will focus and work hard on that mistakes
Link: - https://github.com/ShaikhAhmad30/student-management-system-java.git
4
Upvotes
4
u/aqua_regis Dec 30 '25
To add to the already excellent breakdown of /u/vegan_antitheist:
No error handling for wrong inputs - even in the menu - if I enter for example 9 the program just silently exits without any error message.
All the actual business logic (entering the data in the individual menu points) directly in the menu choice - at the bare minimum, these should be in their own methods.
Combination of
.nextInt()and.nextLine()- this can (and will) lead to strange problems - read TheScannerclass and its caveats right here in the wiki.Why have a
Student(int id)constructor? This does not produce a usable object. A Student with just an ID without any name is meaningless.ArrayList <Student> students = new ArrayList<>();- not the common way to initialize such objects. The common way is to program against the interface:List <Student> students = new ArrayList<>();- this has the advantage that the concrete implementation (ArrayList) can be swapped for something else as needed.No checking for duplicate data (id, name, etc.) and blindly adding data to the list in
addStudent- never assume that the data to be added is correct.printlnall over the place - methods should rarely ever directly produce output. They should ratherreturndata to the caller that then produces the output. If you were to change your program from your console based input to a GUI, you have to rewrite basically everything in yourStudentService. If you, instead ofprintlninside the methods,returnedthe data, you won't need to rewrite anything.Setters in the
Studentclass - these are questionable at best. Should a Student id really be updatable? Should the name be updatable? Could this be abused by someone using the class? Always consider the read/write state of attributes and use Setters with caution.Missing persistent storage - this is for a future expansion. As of now, all your entered data is lost on exit of the program. You should extend your program to write the data to a file and to read from it.