Skip to main content
8 events
when toggle format what by license comment
Jan 3, 2016 at 22:55 comment added thexacre What about handling unchecking the box? In just about every language / UI toolkit I've encountered you'll still need to check the state of the checkbox in the event listener. I agree this is a better pattern, but it doesn't avoid needing basically if flag do something somewhere.
Jan 3, 2016 at 22:48 comment added Tulains Córdova @thexacre No, one listener for each checkbox. In the click event just commands.add(new EncryptCommand()); or commands.add(new CompressCommand()); respectively.
Jan 3, 2016 at 22:45 comment added thexacre So in your checkbox event listener you have "if checkbox.ticked then add command"? It seems to me like you're just shuffling the flag if statements around...
Jan 3, 2016 at 21:47 comment added Tulains Córdova @thexacre I added an example.
Jan 3, 2016 at 21:47 history edited Tulains Córdova CC BY-SA 3.0
added further explanation
Jan 3, 2016 at 19:53 comment added thexacre Unless you can provide an example of "some kind of factory that puts together the command list" without code that essentially looks like Ixrec's answer then IMO this doesn't answer the question. This provides a better way of implementing the compress and encrypt functions, but not how to avoid the flags.
Jan 3, 2016 at 19:21 history edited Tulains Córdova CC BY-SA 3.0
edited body
Jan 1, 2016 at 20:05 history answered Tulains Córdova CC BY-SA 3.0