2

Is there a significant difference in meaning between "Should not be null" and "Should be not null"? Or, maybe, one of the options is wrong?

  • 1
    It would depend on your context. For example, in a trouble ticket, you may write The return value of foo() should not be null if it can update the database successfully. On the other hand, there are several occasions where should/must be "not null" is possible. This following is from MySQL 5.0 Reference Manual: If the column is defined as part of a PRIMARY KEY but not explicitly as NOT NULL, MySQL creates it as a NOT NULL column (because PRIMARY KEY columns must be NOT NULL), but also assigns it a DEFAULT clause using the implicit default value. – Damkerng T. Jun 11 '15 at 9:24
  • @DamkerngT. the context is a comment to a method parameter. Like "This value should be not null". So "Should not be null" is better in this case? – Anastasiia Iurshina Jun 11 '15 at 9:35
  • I agree that should not be null is better in your context. I'd probably use must or can instead of should, though, e.g.: dbHandler - A handle of an already opened database. This value must not be null. – Damkerng T. Jun 11 '15 at 9:40
3

There is a slight difference.

In the first sentence, not modifies the should and says what X should not be, which means here that X should be anything except null.

In the second sentence, should is not modified. The sentence says that X should be not null. So here you're saying what it should be instead of saying what it should not be.

  • Thanks. I was asked to replace the second option with the first one. So, I suppose, they thought that the second option was better or more correct. They both seem ok to me. – Anastasiia Iurshina Jun 11 '15 at 9:13
  • You were asked to replace the first with the second or the other way around? They are definitely not the same. – Sander Jun 11 '15 at 10:39
  • To replace "Should be not null" with "Should not be null". The context is a description of a method parameter. – Anastasiia Iurshina Jun 11 '15 at 10:42
  • Then the second sentence is definitely better. – Sander Jun 11 '15 at 10:58
  • Should is often used instead of must, but must is clear and unambiguous, so I'd use "must" instead of "should": "parameter foo must be not null" or "parameter foo must not be null". – Tᴚoɯɐuo Jun 11 '15 at 12:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.