This question already has an answer here:
I posted the question What is the correct approach rather than using if ( variable != null ) bandage ,
if ( variable != null ) {now do the code that depends on variable}
Followings is a fact : Such approach supresses the business logic that when was written it assumed that a non null object will be provided, now whatever that logic was meant to do is being supressed, and the cause of the issue is being swept under the carpet.
Is there any argument against this? to provide quick fix by bypassing the cause? What is a correct design so that everywhere trough code if ( variable != null )
is not sprinkled? Or Having if ( variable != null )
is a good programming practice?
I am looking for a design patterns or architectural way of handling this not just by using code such as if/else/catch etc.
Aucun commentaire:
Enregistrer un commentaire