"Your suggested reduction in cyclomatic complexity (which I agree with) actually increases your essential complexity... though not above the structured/unstructured threshold. You add an additional exit point to the function, which is a trade off. Your second example:
Additional exit point will not be added since the msg variable will have a default, then you only change the content of the variable when the if statement evaluate to true, and only one return statement is needed.
Very true! Thanks for the comment.
You're absolutely right. I was mixing code samples in my head. Thanks for the correction!
We're a place where coders share, stay up-to-date and grow their careers.
We strive for transparency and don't collect excess data.