What’s the extent should one practice defensive programming?
I have this code which is a bit defensive, so in case someone swapped the left and right expression of OR statement, the code would still work:
&& ( companyId == Guid.Empty
|| (companyId != Guid.Empty && x.StoreCompany.CompanyId == companyId) )
Would you boot me out of your organization if I re-factor that and shortened it to:
&& (companyId == Guid.Empty || x.StoreCompany.CompanyId == companyId)
The shorter/less confusing logical statements are, the better. I’d commend you for doing such a refactor.