• 0 Posts
  • 92 Comments
Joined 8 months ago
cake
Cake day: March 21st, 2024

help-circle











  • If you go back to my example, you’ll notice there is a UserUniqueValidator, which is meant to check for existence of a user.

    Oops, right, I just glanced over the code and obviously missed the text and code had different class names. Another smell in my opinion, choosing class names that only differ in the middle. Easily missed and confusion caused.

    I don’t think our opinions are too far off though. You’re just scaling the validation logic to realistic levels and I warn that in practice coders extrapolate too quickly and too often, which results in too much generic code which is naturally harder to understand and maintain than specific code.


  • I would argue that the validate routines be their own classes; ie UserInputValidator, UserPasswordValidator, etc.

    I wouldn’t. Not from this example anyway. YAGNI is an important paradigm and introducing plenty of classes upfront to implement trivial checks is overengineering typical for Java and the reason I don’t like it.

    Edit: Your naming convention isn’t the best either. I’d expect UserInputValidator to validate user input, maybe sanitize it for a database query, but not necessarily an existence check as in the example.








  • I disagree. Scaled down to small and harmless it’s like handling kids. You explain what you don’t want them to do and what happens/you’re going to do if they continue. Now it’s crucial you go through with what you threatened them with.

    If you either don’t deliver on the “threat” or don’t act as you said you would, guess what happens? They just continue or it even gets worse.

    Of course it’s more delicate/difficult when handling with powerful and intelligent adults but it’s at least similar. Not issuing threats is just not communicating. If you then just act (violently), things are more likely to escalate.

    Edit: or back to the kids analogy: don’t tell them anything but smack them once they went too far: may help in that instance but they’ll just learn to better avoid you and do shit behind your back.