Extract method control flow - option to flip boolean return value meaning
the extract method case where control flow is affected is brilliant and incredibly useful.
Except that, in some cases, such as when something positive is being done, I want it to return false if it should exit the parent.
eg if the method being extracted was to be called “TryAddRoleToUser”
I'd expect this to return true oif it was successful, and false if not.
I would typically want to continue in the success case.
eg
if (!TryAddRoleToUser(…))
{
do some remedial actions
}
Please sign in to leave a comment.
Hello David,
thank you for contacting us.
Looks like your request can be done by the existing Extract Method functionality. We assume that your code is properly prepared for such refactoring.
For example:
Select the two first lines in this method and perform the Extract Method. The result will be like this:
Please confirm that this example solves the issue. Otherwise please provide more details on your request and sample code.
Thank you!