Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using nullable types in public APIs

I have a method in DAL like:

public bool GetSomeValue(int? a, int?b, int c)
{
   //check a Stored Proc in DB and return true or false based on values of a, b and c
}

In this method, I am passing two nullable types, because these values can be null (and checking them as null in DB Stored Proc). I don't want to use magic numbers, so is it ok passing nullables types like this (from performance as well as architecture flexibility perspective)?

like image 861
Raghav Avatar asked Aug 04 '09 14:08

Raghav


2 Answers

I think this is perfectly valid - I prefer nullable types to magic values also.

like image 108
bernhardrusch Avatar answered Oct 09 '22 02:10

bernhardrusch


Since nullable types are part of the Base Class Library and not related to any specific language I find it perfectly valid. The only thing that I try to stay away from in public API's are constructs that are language-specific.

like image 25
Fredrik Mörk Avatar answered Oct 09 '22 03:10

Fredrik Mörk