One option is to reorganize each of the core logic elements ( canDeleteSires , deletingSearchGroup || wasSearchGroup ) into methods with names that describe the readable version of the logic:
if (WeAreInSearchGroup()) { if (WeAreDeletingAllSires()) { deletedSire = new ArrayList(); deletedSire.AddRange( sireGroupBE.SireList); } else { deletedSire = GetDeleteSire(sireGroupBE.SireList); } }
Then you encapsulate your current logical logic inside these methods, how you pass the state (method arguments or class members) is a matter of taste.
This will remove the boolean elements from the main method into smaller methods that ask and answer the question directly. I saw this approach used in the style of "comments - evil." Honestly, I find this a bit crowded if you are a lone wolf, but on a team it is much easier to read.
From personal preferences, I would also invert your first if statement to return earlier, this will reduce the indentation level of the whole method:
if (searchAllSireList) { return result; } DataAccessDialog dlg = BeginWaitMessage(); bool isClose = false; try ...
But then you can be punished by a mob of "multiple returns of evil." I have developed the practice of developing an impression, as in politics ...
source share