mercredi 4 février 2015

Should methods perform checks that they accomplished the task they were built for? or should they just throw an exception?


What are some pro's and con's of validating your performed the task intended?



public static bool UploadFile(string filename)
{
// 1. upload the file
// 2. check to see if the file now exist on the server and return status
}


vs.



public static void UploadFile(string filename)
{
// 1. upload the file and hope it's on the server now, or check with another method to see if the file exist on the server
}




Aucun commentaire:

Enregistrer un commentaire