About the non-nullable types debate

前端 未结 7 524
北海茫月
北海茫月 2020-12-20 18:07

I keep hearing people talk about how non-nullable reference types would solve so many bugs and make programming so much easier. Even the creator of null calls it his billion

7条回答
  •  囚心锁ツ
    2020-12-20 18:26

    Non-nullable types make more sense to me when we are dealing with domain objects. When you are mapping database tables to objects and you have non-nullable columns. Say you have a table called User and it has column userid varchar(20) not nullable;

    That would be so convenient to have a User class with UserId string field which is not nullable. You cab reduce some bugs at compile time.

提交回复
热议问题