With an IoC container, should a constructor still check if a parameter is
null?
I was looking through the Orchard CMS Project source code and I noticed
that some of their constructors never varify that the required parameter
is not null. At first, I thought this was odd thinking, "Considering that
you're saying this dependency is required, wouldn't you want to check that
you actually have one?" Realizing that the project uses Castle Windsor as
an IoC container, I later then thought, "Well, the container would have
thrown the exception for the object that had the requirement." So my
question stands, should I still check when I know that an IoC contianer
will check for me?
Or is the double check good because I'm, in a sence, adhering to a reverse
encapsulation princible stating: "I don't know how I'm getting this
dependency, but I really need one!"
No comments:
Post a Comment