Lazy Developers?
When I was out with my new dog (I Chihuahua, wonderful dog),
I was thinking about Defensive Programming and Design by
Contract. I like to do some refactoring and help other
people to write cleaner code etc, not that I’m an expert in
the area but I think most of developers can see stuff that
blinds other developers during development. I remember a
scenario that made me kind of mad, I often notice that some
developers doesn’t even care to validate arguments on public
API or other methods, they assume the caller pass in the
right values. When I started to develop apps, I didn’t
validate arguments (In know I was a noob ;)). But since I
started to do validation, it reduces the number of bugs in
my code, and the difference was big. But that isn’t the only
reason I like to do validation. Another reason is because
the caller of the method should know if they have passed a
wrong value, there are of course some other reasons also,
but the main reason is make sure the caller or the method
pass in the correct value, and if they do, they will get
what they want.
I notice that several developers
today don’t care about validation, I ask them why and they
all gave me the same argument “Why should I, it will only
make me add more code and it’s boring to write code that
checks values”. Can this be summarized that some developers
are lazy?
Maybe I’m stupid because I get mad when
I hear that kind of argument, but I’m special ;)