Jump to content

Do I need to check the arguments of a public function if I test the input before


HGeneAnthony

Recommended Posts

I don't know if this is even an issue, but I was wondering with a public function of a class, do I need to test the arguments to see whether the data is valid even if I test the data before I pass it to the function? 

 

For example, I have a class to manage the users in my system.  The class is responsible for checking the input it's passed to make sure it's allowed, only after it's done will it send the data to my seperate database class which handles the database details.  The database class is set up with public functions so it can receive the data from the user manager class.  Nothing else is set up to touch the database class.  Do I still need to check the data?  Can someone somehow access the database classes public functions in ways I hadn't planned for?  I can't think how they would but I'd like to know if this is something I should worry about because I'd like to put a lot of the logic in the user manager class and keep the database class simple.  Also this system makes it much easier to use mock objects which I can't do nearly as well otherwise.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.