Last active
May 9, 2025 16:23
-
-
Save VovaStelmashchuk/aad196104c489b57e49b1d2ff43d23fc to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun runBarFlowBad() { | |
if ( | |
user.role == UserDto.Role.ADMIN || | |
(user.status == UserDto.Status.VIP || | |
(user.status == UserDto.Status.TRIAL_VIP && user.paymentTransactionList.isNotEmpty()) | |
&& user.age.isAdult()) | |
) { | |
// do something | |
} else { | |
// do something else | |
} | |
} | |
fun runBarFlowGood() { | |
val isAdmin = user.role == UserDto.Role.ADMIN | |
val isUserHasUnCompletePayment = user.status == UserDto.Status.TRIAL_VIP && user.paymentTransactionList.isNotEmpty() | |
val isUserHasPayments = user.status == UserDto.Status.VIP || isUserHasUnCompletePayment | |
val isUserAdult = user.age.isAdult() | |
val isNormalUserHasAccessToFeature = isUserAdult && isUserHasPayments | |
if (isAdmin || isNormalUserHasAccessToFeature) | |
) { | |
// do something | |
} else { | |
// do something else | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment