--

Null is the billion dollar mistake and also a code smell.

function carBrandExplicit(model) {

if (model === 'A4') {

return 'audi';

}

if (model === 'AMG') {

return 'Mercedes-Benz';

}

// Fail Fast

throw new Exception('Model not found);

}

this function either returns the first two values or throws an excepcion.

No nulls are involved

--

--

Maximiliano Contieri
Maximiliano Contieri

Written by Maximiliano Contieri

I’m a senior software engineer specialized in declarative designs. S.O.L.I.D. and agile methodologies fan. Maximilianocontieri.com

Responses (1)