We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Agree for if-else as better readability for long term maintenance than ternary-opreator but a better code would use "else" a better way, not adding un-necessary "age >= 13 &&" and "age >= 18 &&" as it increases the bug risk if boundaries are not correcly duplicated. Moreover in case of age boundary evolution (let's old is starting à 45), this solution have to be changed at two places, increasing risk of bug.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Day 4: Class vs. Instance
You are viewing a single comment's thread. Return to all comments →
Agree for if-else as better readability for long term maintenance than ternary-opreator but a better code would use "else" a better way, not adding un-necessary "age >= 13 &&" and "age >= 18 &&" as it increases the bug risk if boundaries are not correcly duplicated. Moreover in case of age boundary evolution (let's old is starting à 45), this solution have to be changed at two places, increasing risk of bug.