Skip navigation
Currently Being Moderated

Need more info about "AlertShow" violation

Sep 10, 2009 12:36 PM

Hello,

 

First of all thanks for the great tool! It was really something we all missed.

 

I have a question related to the "AlertShow" violation. I got several such violations and the description says

"Do not call Alert.show directly.. You should not Alert.show() directly. If an error occurred in the system, you should probably use an ErrorManager to have a consistent way to manage those errors".

What exactly was meant by this violation? Could you, please provide more details why this violation pops up and how it is expected to be fixed.

 

Thank you!

 
Replies
  • Currently Being Moderated
    Sep 10, 2009 10:38 PM   in reply to smirnoff81

    Hi,

     

    Glad you liked the project.

     

    So we often people using Alert.show whithout having a central ErrorManager class. Having such a class allows you to have a consistent way to deal with errors in your application.

     

    Alert.show can be called from anywhere (view, model, commands, ...), whereas it is nothing else than a wrapped view.

    I hope this helps.

     

    Xavier

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 13, 2011 3:40 AM   in reply to Xavier Agnetti

    PMD found these Alerts in my code too. I fail to see what is wrong with that.

    What would an ErrorManager do more than report the error and wait for OK to know that the user saw it?

    What to do after the error depends entirely on the place the error occurred, and

    cannot be dealt with in a general way. Except maybe for logging it for later examination. Is that what you mean?

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 13, 2011 6:53 AM   in reply to Jandr123

    Using Alerts all over the place can have lots of drawbacks:

     

    1. They are not good from a unit testing perspective, it's very hard to make assertions based on alerts. An Alert itself should not be used directly to specify errors. Otherwise, and highly likely, in a testrunner you'll end up having a ton of alerst one on top of the other without the ability to assert the expected behaviour

     

    2. Normally applications have a centralized way to present messages or errors to the user. Allowing developers to simply allow the usage of Alerts will highly imply that when there's an error multiple alerts appear one on top of hte other.

     

    3. Using or referencing an Alert from a model is not a "permitted" relationship. A PM or model shouldn't refernece the view, the view should reference the model (not hte other way arround).

     

    does this make sense?

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 13, 2011 11:02 PM   in reply to Xavi Beumala

    I see what you mean: I've had multiple alerts on top of the other as well.

    But as I am relatively new to flex, I do not know how to go about setting

    up an ErrorManager class.

    What would it do to fix the problems you are addressing?

    I have searched in the Adobe documentation (and google) for ErrorManager,

    but apparently its use

    is not that widespread to have found its way into that documentation and

    examples.

    Please point me to an example?

    Jan

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points