0
How to code properly
Hi, in my practicing with different classes, I have a doubt, when you need to perform a check or operation, do you do it in the class that you create for your objects, or in the main class? I explain with an example, if I create a class car, and it have an Id with 9chars, should I check that the minimum chars are correct in main or in the car class?
2 Answers
+ 3
i would create a 3rd Class in your example - a validator class.
i use model classes only for proprties, getter and setter.
normaly i have a package validator with all kinds of validation classes, or a package called utils or helper wher i have helper classes for this kind of code.
but thats only "my" style of coding ;)
0
thanks for your answer @R4xx4r I have another question. Do you create in that third class the methods for validations as static? I recently studied static and I think I understood it, but I don't know is this situation could be the optimal for use it.