I have poster another question similar and got great response. I haven't implemented some of the feature like return immutable lists, not use throws for main here but grasped the concepts.
I have poster another question similar and got great response. I haven't implemented some of the feature like return immutable lists, not use throws for main here but grasped the concepts.
Simple Object Oriented desingobject oriented design of Student Systemstudent system
I have created a simple system to get hands on experience with OOPS design and some features in java.Java:
The system is:
A ClassOfStudents contains Students
A Student contains list of scores
A Student can be a PartTimeStudent or FullTimeStudent
A score is valid only if it is between 20 and 100
- A
ClassOfStudents
contains Students - A
Student
contains a list of scores - A
Student
can be aPartTimeStudent
orFullTimeStudent
- A score is valid only if it is between 20 and 100
I have:
Used enum for gender as it is set of constants
Created User defined exception to check for business rule
Made student as abstract , to make it extensible
Used compare to reverse the natural order of sort and able to sort students
- Used enum for gender as it is a set of constants
- Created a user-defined exception to check for business rule
- Made student as abstract to make it extensible
- Used compare to reverse the natural order of sort and able to sort students
Queries
Please go through the code and feel free to advice all the OOPS design enhancements. I am new to OOPS and want to really understand.How to make code more extensible, reusable, secure. Some of the questions I have encountered while coding are
1.I dont want to create a object when score is not valid. I can achieve this by checking for score before using creating an object. But is there any other way?
2.I am throwing an user defined exceptionPlease go through the code and catching it immediately, is it a good practice. I don't wantfeel free to interruptadvice all the flow and continue
3OOPS design enhancements.I I am using logging for the first time. Is it the good way to log?
4.I tirednew to implement as many as OOPS concepts but unable to think of interface. Please suggest the good use caseand want to use interface.
5really understand.How can I improve the exception handling? (Robustness)
Is there any other way I can add the student to studentList in the ClassOfStudents whenever a new student is created?
6. Also suggest some new feature I can add to learnmake code more OOPS/Java conceptsextensible, reusable, secure. Some of the questions I have encountered while coding are:
- I don't want to create a object when score is not valid. I can achieve this by checking for score before using creating an object. But is there any other way?
- I am throwing an user defined exception and catching it immediately. Is it good practice? I don't want to interrupt the flow and continue.
- I am using logging for the first time. Is it the good way to log?
- I tired to implement as many as OOPS concepts but am unable to think of an interface. Please suggest a good use case to use an interface.
- How can I improve the exception handling (robustness)? Is there any other way I can add the student to
studentList
in theClassOfStudents
whenever a new student is created? - Also suggest some new feature I can add to learn more OOPS/Java concepts.
PS: I I have poster another question similar and got great response.I I haven't implemented some of the feature like return immutable lists, not use throws for main here but grasped the concepts :).
Simple Object Oriented desing of Student System
I have created a simple system to get hands on experience with OOPS design and some features in java.
The system is:
A ClassOfStudents contains Students
A Student contains list of scores
A Student can be a PartTimeStudent or FullTimeStudent
A score is valid only if it is between 20 and 100
I have:
Used enum for gender as it is set of constants
Created User defined exception to check for business rule
Made student as abstract , to make it extensible
Used compare to reverse the natural order of sort and able to sort students
Queries
Please go through the code and feel free to advice all the OOPS design enhancements. I am new to OOPS and want to really understand.How to make code more extensible, reusable, secure. Some of the questions I have encountered while coding are
1.I dont want to create a object when score is not valid. I can achieve this by checking for score before using creating an object. But is there any other way?
2.I am throwing an user defined exception and catching it immediately, is it a good practice. I don't want to interrupt the flow and continue
3.I am using logging for the first time. Is it the good way to log?
4.I tired to implement as many as OOPS concepts but unable to think of interface. Please suggest the good use case to use interface.
5.How can I improve the exception handling? (Robustness)
Is there any other way I can add the student to studentList in the ClassOfStudents whenever a new student is created?
6. Also suggest some new feature I can add to learn more OOPS/Java concepts.
PS: I have poster another question similar and got great response.I haven't implemented some of the feature like return immutable lists, not use throws for main here but grasped the concepts :)
Simple object oriented design of student system
I have created a simple system to get hands on experience with OOPS design and some features in Java:
The system is:
- A
ClassOfStudents
contains Students - A
Student
contains a list of scores - A
Student
can be aPartTimeStudent
orFullTimeStudent
- A score is valid only if it is between 20 and 100
I have:
- Used enum for gender as it is a set of constants
- Created a user-defined exception to check for business rule
- Made student as abstract to make it extensible
- Used compare to reverse the natural order of sort and able to sort students
Queries
Please go through the code and feel free to advice all the OOPS design enhancements. I am new to OOPS and want to really understand.How to make code more extensible, reusable, secure. Some of the questions I have encountered while coding are:
- I don't want to create a object when score is not valid. I can achieve this by checking for score before using creating an object. But is there any other way?
- I am throwing an user defined exception and catching it immediately. Is it good practice? I don't want to interrupt the flow and continue.
- I am using logging for the first time. Is it the good way to log?
- I tired to implement as many as OOPS concepts but am unable to think of an interface. Please suggest a good use case to use an interface.
- How can I improve the exception handling (robustness)? Is there any other way I can add the student to
studentList
in theClassOfStudents
whenever a new student is created? - Also suggest some new feature I can add to learn more OOPS/Java concepts.
I have poster another question similar and got great response. I haven't implemented some of the feature like return immutable lists, not use throws for main here but grasped the concepts.
1.I dont want to create a object when score is not valid. I can achieve this by checking for score before using creating an object. But is there any other way?
2.I am throwing an user defined exception and catching it immediately, is it a good practice. I don't want to interrupt the flow and continue
3.I am using logging for the first time. Is it the good way to log?
4.I tired to implement as many as OOPS concepts but unable to think of interface. Please suggest the good use case to use interface.
5.How can I improve the exception handling? (Robustness)
Is there any other way I can add the student to studentList in the ClassOfStudents whenever a new student is created?
6. Also suggest some new feature I can add to learn more OOPS/Java concepts.
1.I dont want to create a object when score is not valid. I can achieve this by checking for score before using creating an object. But is there any other way?
2.I am throwing an user defined exception and catching it immediately, is it a good practice. I don't want to interrupt the flow and continue
3.I am using logging for the first time. Is it the good way to log?
4.I tired to implement as many as OOPS concepts but unable to think of interface. Please suggest the good use case to use interface.
5.How can I improve the exception handling? (Robustness)
Is there any other way I can add the student to studentList in the ClassOfStudents whenever a new student is created?
6. Also suggest some new feature I can add to learn more OOPS/Java concepts.
1.I dont want to create a object when score is not valid. I can achieve this by checking for score before using creating an object. But is there any other way?
2.I am throwing an user defined exception and catching it immediately, is it a good practice. I don't want to interrupt the flow and continue
3.I am using logging for the first time. Is it the good way to log?
4.I tired to implement as many as OOPS concepts but unable to think of interface. Please suggest the good use case to use interface.
5.How can I improve the exception handling? (Robustness)
Is there any other way I can add the student to studentList in the ClassOfStudents whenever a new student is created?
6. Also suggest some new feature I can add to learn more OOPS/Java concepts.