Using bool return methods, my plan is to stop the remainder of all the
rest of the error checking methods if any unwanted criteria was found.
Reason being of course, if an error surfaced there would not be a need
to continue checking anything else until the error has been corrected.
My goal is to ensure I write this the most simple, yet modularized way
possible.
My question is...
Have I written this the best way to stop the process of error checking
if an error is found in any one of the error checking methods?
Beneath I provided a generic example of the "LoadFile" method.
public void LoadFile(string fPath)
{
bool noError = false;
ArrayList myList = new ArrayList();
if (File.Exists(fPath)) { noError = true; }
if (noError) { myList = new ArrayList(File.ReadAllLines(fPath)); }
if (noError) { noError = ErrorCheckForEmptyData(myList); }
if (noError) { noError = ErrorCheckDelimitedData(myList); }
if (noError) { noError = ErrorCheckCommentedNotes(myList); }
if (noError)
{
myList = RemoveTrailingBlankLines(myList);
myList = TrimInteriorBlankLines(myList);
myList = RemoveDuplicateEntries(myList);
WriteNewData(myList, fPath);
}
else
{
MessageBox.Show("an error discovered in file");
}
}
Beneath I provided a generic example of modularized calls.
// Error Check For Empty Data
private bool ErrorCheckForEmptyData(ArrayList myList) {
return noError;
}
// Error Check Delimited Data
private bool ErrorCheckDelimitedData(ArrayList myList) {
return noError;
}
// Error Check Commented Notes
private bool ErrorCheckCommentedNotes(ArrayList myList) {
return noError;
}
// Remove Trailing Blank Lines
private ArrayList RemoveTrailingBlankLines(ArrayList myList) {
return myList;
}
// Trim Interior Blank Lines
private ArrayList TrimInteriorBlankLines(ArrayList myList) {
return myList;
}
// Remove Duplicate Entries
private ArrayList RemoveDuplicateEntries(ArrayList myList) {
return myList;
}
// Write New Data
private void WriteNewData(ArrayList myList, string fPath) {
// Writes New Data...
}

New Topic/Question
Reply




MultiQuote






|