dimanche 16 novembre 2014

How can I avoid duplicate code in the if-else chain?


Vote count:

0




I have the following code snippet


if(!setPass){ this.teacher = Ev_TeacherTestUtil.createTeacher (sess, 'TestTeacher1', Ev_TeacherService.NOMINATED, Ev_TeacherService.EMPLOYEE_NO, Ev_TeacherService.PASS_NO); }else{ this.speaker = Ev_TeacherTestUtil.createTeacher (sess, 'TestTeacher1', Ev_TeacherService.NOMINATED, Ev_TeacherService.EMPLOYEE_NO, Ev_TeacherService.PASS_YES); }


The only change in the else condition is Ev_TeacherService.PASS_YES (in the if condition it is set to Ev_TeacherService.PASS_NO), the rest is just being duplicated! How can I avoid this? Thanks in advance for the help!



asked 48 secs ago

Nish

13






How can I avoid duplicate code in the if-else chain?

Aucun commentaire:

Enregistrer un commentaire