I’m wondering if this is good, bad?
SelectRecipientResponse user = SomeUtil.SelectRecipient(p.Email, p.ListID.ToString());
bool userIsInList = user.ExistsInList;
bool userIsOptedOut = user.IsOptedOut;
user = null;
user = SomeUtil.SelectRecipient(p.Email, _masterSuppressionListID);
bool userIsInSupressionList = user.ExistsInList;
so I’m using one instance of user to check to see if they are in 2 lists. Lists I am checking are over a 3rd party API. I want to do one check, null out that object and reuse it again.
Does this seem typical? I’m just trying to code this smartly so wanted to see what one thinks about this technique above.
You’re asking for trouble when some other developer comes back in a year and starts working with user further down in the method not noticing that you overwrote it with a second assignment. Name your variable what it is. This would probably qualify as unnecessary premature optimization.