mercredi 5 septembre 2018

java how to Improve the Design/Architecture of my Programm?

i have a Programm that is:

  1. Downloading files from an Ftp Server to a local directory.
  2. The parsed file contents will be written to a database and to another Ftp-server. The download/transfer can take while(in total 50GB of files transfered/downloaded).

If the Programm completely fails. I would have to restart the whole transfer/downloading process. So i added Error-Handling which enables me to continue on the point where my Programm was interrupted. What i dont like is the way my architecture looks like:

main(){
switch (whereToContinueProgramm) {
            case "resumeDownloading":
                resumeDownloadingFiles(targetDirectory.getPath().toString());
                xmlFiles = Arrays.asList(targetDirectory.listFiles());
                doImport(xmlFiles);
                break;

            case "resumeImport":
                // All Files have already been downloaded so skip the download process
                xmlFiles = Arrays.asList(targetDirectory.listFiles());
                doImport(xmlFiles);

            default:
                //regular processing, start programm normally
                downloadFiles(targetDirectory.getPath().toString());
                xmlFiles = Arrays.asList(targetDirectory.listFiles());
                doImport(xmlFiles);

                break;
            }
}

in the near feature there will be added smth. like:

switch (import_mode) {
        case "daily":
        //code you have seen above,logic of downloadFiles will be different.
        switch (whereToContinueProgramm);

        case "initial":
        //code you have seen above
        switch (whereToContinueProgramm);
}               

Do you have any advices how to improve this architecture/design of this problem ?

Aucun commentaire:

Enregistrer un commentaire