Skip to main content
added 208 characters in body
Source Link
candied_orange
  • 119.7k
  • 27
  • 233
  • 369

Two things to always consider:

  1. Consider which leaves your code most responsive to change

  2. Consider which is easier to read

1 might argue for current if the flag value might ever be something other than null, I don't see that happening myself.

2 argues for null because it says flat out: if you're here, you're returning null. Even makes life in the debugger easier.

On balance, I'll take return null here.

The views presented here should in no way be construed as an endorsement of null.

Two things to always consider:

  1. Consider which leaves your code most responsive to change

  2. Consider which is easier to read

1 might argue for current if the flag value might ever be something other than null, I don't see that happening myself.

2 argues for null because it says flat out: if you're here, you're returning null. Even makes life in the debugger easier.

On balance, I'll take return null here.

Two things to always consider:

  1. Consider which leaves your code most responsive to change

  2. Consider which is easier to read

1 might argue for current if the flag value might ever be something other than null, I don't see that happening myself.

2 argues for null because it says flat out: if you're here, you're returning null. Even makes life in the debugger easier.

On balance, I'll take return null here.

The views presented here should in no way be construed as an endorsement of null.

Source Link
candied_orange
  • 119.7k
  • 27
  • 233
  • 369

Two things to always consider:

  1. Consider which leaves your code most responsive to change

  2. Consider which is easier to read

1 might argue for current if the flag value might ever be something other than null, I don't see that happening myself.

2 argues for null because it says flat out: if you're here, you're returning null. Even makes life in the debugger easier.

On balance, I'll take return null here.