1 Reply Latest reply: Mar 17, 2010 7:34 PM by jschellSomeoneStoleMyAlias RSS

    please help me design this

    513500
      here is my code
           public boolean isLastProgram(EaAuditProgram eaAuditProgram, WorkflowName  workflowName) {
                StgAuditGeneral  stgAuditGeneral=eaAuditProgram.getStgAuditGeneral();
                for(EaAuditProgram program:stgAuditGeneral.getLiveAuditPrograms() ){
                     if(program.equals(eaAuditProgram))continue;
                     WFEntity  wfEntity=getWfAuditProgramEntity(program, workflowName);
                     if(wfEntity==null) return  false;
                     if(!workflowService.getStepName(wfEntity).equals(WorkflowSteps.COMPLETED_AUDIT_PROGRAM_QUEUE.toString())){
                          return false;
                     }
                }
                return true;
           }
      the above code is trying to check some conditions for each EaAuditProgram , I used two if conditions one is if(wfEntity==null) and other is if(!workflowService.getStepName(wfEntity).equals(WorkflowSteps.COMPLETED_AUDIT_PROGRAM_QUEUE.toString())
      and tomarrow I might add more conditions , to avoid the ugly if code blocks I want to use a design pattern please suggest me what is applicable here and how
        • 1. Re: please help me design this
          jschellSomeoneStoleMyAlias
          miro_connect wrote:
          to avoid the ugly if code blocks I want to use a design pattern
          That isn't how it works.

          A Pattern represents a way that is often used to implement some bit of functionality. Nothing more. It certainly has nothing to do with minimizing how much typing you need to do.
          and tomarrow I might add more conditions ,
          The best way to create general solutions is to start with several specific solutions. The more then better. If you only have one then it is much harder.