loading...

Discussion on: DevTips: Use early returns to avoid nested conditions

yannbertrand profile image
Yann Bertrand

Agreed! I was not inspired, thanks for going further 🙂

Thread Thread
jouana profile image
Antoine Jouan

I am agreed with your improvement expect for adding predicate to user class.
This will break Single Reponsability principle.
I think it's better to make a class for predicate which will manage specification and one class for user which will manage user state.
So if you want to keep this syntax then you can set predicate as extension of user class but in js it's little tricky and not simple for beginner.

Thread Thread
thomasjunkos profile image
Thomas Junkツ

I do not quite understand. Starting with "classes". You could do that without classes at all. Plain objects will do.