Quantcast
Channel: Question and Answer » encapsulation
Viewing all articles
Browse latest Browse all 12

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

0
0

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
}

Viewing all articles
Browse latest Browse all 12

Latest Images

Trending Articles





Latest Images