GithubHelp home page GithubHelp logo

tpexceptionsthomasdonnay's People

Contributors

dons9011 avatar

Watchers

 avatar  avatar

tpexceptionsthomasdonnay's Issues

Correction

Acquis. Travail complet mais attention à la duplication de code et à ne pas mettre dans un bloc try des instructions ne pouvant lever d'exceptions !
Mets tes regex en constantes

if (!ligne.matches("^[MTC]{1}.*")) {
throw new BatchException("Type d'employé inconnu : " + ligne.charAt(0));
}
if (ligne.matches("^[M]{1}.*")) {
processManager(ligne);
}
if (ligne.matches("^[C]{1}.*")) {
processCommercial(ligne);
}
if (ligne.matches("^[T]{1}.*")) {
processTechnicien(ligne);
}

Tu peux mettre en commun tous les traitements qui sont les mêmes pour tous les types d'employés (matricule, nom, prénom, salaire, date d'embauche),pour éviter le copier coller de code.

Aucune exception ne peut être levée ici...

try {
String strMatriculeman = ligneman[0];
man.setMatricule(strMatriculeman);
} catch (Exception e) {
throw new BatchException("Probleme avec le matricule : " + ligneman[0]);
}
;

Ni là....

// nom et prenom
try {
String strPrenomman = ligneman[1];
String strNomman = ligneman[2];
man.setPrenom(strPrenomman);
man.setNom(strNomman);
} catch (Exception e) {
throw new BatchException("Probleme avec les nom et prenom : " + ligneman[1] + "et " + ligneman[2]);
}
;

Pourquoi avoir distinguer les deux cas ? Je ne pense pas qu'une autre exception que NumberFormatException puisse être lancée.

} catch (NumberFormatException p) {
throw new BatchException("Probleme avec le parsing du salaire : " + ligneman[4]);
} catch (Exception e) {
throw new BatchException("Probleme avec le salaire : " + ligneman[4]);
}

Là non plus aucune exception possible.

try {
HashSet<Technicien> strEquipeman = new HashSet<Technicien>();
man.setEquipe(strEquipeman);
} catch (Exception e) {
throw new BatchException("Probleme avec le HashSet de l'equipe ");
}
;

A quoi sert cette ligne ? Aussi, tu ne recherches que dans la base, pas dans le fichier.

Manager managerOftechBidon = managerRepository.findByMatricule(strManagertech);

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.