vb.net - Alternatives to returning Nothing (Null) when unable to use exceptions -


i'm facing problem @ work on very big system which, because of server performances , ressources, can't have exceptions managment. instead, system architects have decided return nothing when, exemple, database connector finds nothing. system coded in vb.net.

i aware returning , passing nothing bad habbit various reasons such violation of of solid principles, noise in code null checks , addition of fragility because of nullpointerexceptions can passed-by. alongside fact returning nothing can mean hell lot of things (did crash?, did encountered error 1 of dependencies?, parameters valid?...) book "clean code" robert c. martin (or uncle bob) talks saying it's not practice.

the question alternatives returning null not old doesn't give alternatives on instead of returning nothing.

there's null object pattern. read on subject community seems divided in 2 camps, discourage use saying it's hiding faulty design , says it's actualy solution.

i want propose clean, professional , solid solution. alternative implies clean codification et design while not taking of precious server ressources? since new in professional domain know guru/expert , how he/she face problem. i'm seeking

thanks lot (sorry, english not primary language)

as indicated, using null object pattern hide fault bad idea. here examples how use null object properly: null object pattern

in many cases, null object not right solution because merely replaces null (nothing) reference. can use special case pattern carry more information , produce rich response on client.

if neither right, if it's impossible produce valid object, can choose return empty collection instead of object. here details: option functional type

hope helps. keep on mind faults should not hidden objects. if operation has failed, throw exception. but, if failed operation regular case (i.e. not exceptional), try design special cases represent negative scenarios.


Comments

Popular posts from this blog

javascript - Karma not able to start PhantomJS on Windows - Error: spawn UNKNOWN -

c# - Display ASPX Popup control in RowDeleteing Event (ASPX Gridview) -

Nuget pack csproj using nuspec -