java - Validating arguments to a method -
I have the best practice to validate logic for a method when the argument is contained within a method. For example, if you have:
student of public class {public ink} scholarship (); Public string getStudentName (); Public string getStudentSSN (); Public double getStudentGpa (); Public string millstudent major (); // Other Student related Gators}
Again, I have a method:
Public Zero Print Stendent Report (student student);
In this method, I need to do the logic of ID, name, GPA, and the key. Therefore, it is necessary that all the other student witnesses do not need to be populated Is it ok to validate student object for the first time and then those four methods are needed? I think that this is a bit misleading because I am going through this method, even then all areas are not required, so in reality this half-populated object is being sent on this method. Just seems strange to me
If some properties should populate forever always be valid for a student For, you should define a Nandfelt constructor with the required parameters, and remove any default constructor from the class (and validate the property values within the gates if necessary), ensuring that only valid student items Can become
If the other properties are actually optional for the students, then it seems absolutely okay to me, of course, you need to think about the use cases and carefully analyze the domain model, so that It can be decided which parameters are necessary and which is optional.
Comments
Post a Comment