Results 1 to 2 of 2
  1. #1
    garnaout is offline Member
    Join Date
    Sep 2011
    Posts
    17
    Rep Power
    0

    Default Quick Advice on bad design

    I am reading an array list through an Iterator. There are several displayModes that the user chooses previously (stored in an ArrayList) to decide whether to displayAll or disPlay portions of the screen.

    Java Code:
            ListIterator<String> iterator = myEventsList.listIterator();
    		
    		float triggerTime          = Float.parseFloat(iterator.next().trim());
            String varA     = iterator.next();
            String varB     = iterator.next();
            String varC     = iterator.next();
            String varD     = iterator.next();
            
            ArrayList<String> varE = new ArrayList<String>();
    
            while(iterator.hasNext())
            {
              // all the rest 
              varE.add(iterator.next()); 
            }
    
            // loop through all chosen display modes
            for(int i=0; i < chosenDisplayMode.size(); i++)
            {
                // no restrictions case - display all
                if(chosenDisplayMode.get(i).equals(DisplayMode.DISPLAY_ALL)) 
                { return true; }    
                
    
                else if(chosenDisplayMode.get(i).equals(DisplayMode.DISPLAY_PART1)) 
                {
                    if(varA.equals("part1")) {return true;}  
                }
                
                else if(chosenDisplayMode.get(i).equals(DisplayMode.DISPLAY_PART2))
                {
                    if(varA.equals("part2")) {return true;}
                }
                
                else if(chosenDisplayMode.get(i).equals(DisplayMode.DISPLAY_IF_BOLD))
                {
                    if(varC.equals("BOLD")) {return true;}
                }
                
                // display static only
                else if(chosenDisplayMode.get(i).equals(DisplayMode.DISPLAY_DYNAMIC))
                {
                    if(varD.equals("DYNAMIC")) {return true;}  
                }

    looks to me a like a lot of if else statements....

  2. #2
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,432
    Blog Entries
    7
    Rep Power
    20

    Default Re: Quick Advice on bad design

    Not knowing about any details, I think the decision should be made by the DisplayMode object.

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

Similar Threads

  1. Preview design vs Run design
    By diamonddragon in forum NetBeans
    Replies: 3
    Last Post: 02-06-2012, 08:11 AM
  2. advice
    By icedust in forum Advanced Java
    Replies: 1
    Last Post: 10-10-2011, 11:50 PM
  3. Replies: 2
    Last Post: 03-03-2011, 08:23 AM
  4. looking for OO advice
    By intrepid604 in forum New To Java
    Replies: 7
    Last Post: 02-16-2011, 05:01 PM
  5. Im new n looking for an advice
    By azlynn in forum New To Java
    Replies: 2
    Last Post: 12-10-2009, 02:47 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •