|
|
|
|
|
by ebrenes
3646 days ago
|
|
And why not just make it clear that valid_data depends on valid_user? valid_user = loggedIn() && hasRole(ROLE_ADMIN)
valid_data = valid_user && data != null && validate(data)
if (valid_user && valid_data) …
I think this makes it clear that valid_data has a dependency on valid_user that was being hidden in the previous version, which we're now making clear. It will look a bit weird, but I think that's a positive because it draws attention to the fact that the short-circuiting is required and that double-look coupled with a short comment will make everything much more readable. The previous version does not convey as much meaning, in my opinion. if (loggedIn() && hasRole(ROLE_ADMIN) &&
data != null && validate(data)) …
|
|