Well it probably won't be a noticeable boost. The assertion code is
just removed completely during compilation, so the code is smaller and
those if statements aren't executed. The idea is that Runtime
exceptions that happen on the client side won't be noticed by the user
anyway if they aren't caught (they'll see a Javascript error if they
look at a browser console), so errors should be caught and displayed
in other ways.

--
Arthur Kalmenson



On Thu, Feb 11, 2010 at 3:19 PM, Nathan Wells <[email protected]> wrote:
> Thanks Paul...
>
> So I am right in my understanding it gives a noticeable boost to
> performance when we use this -
>
> assert (methodArgument != null) : "methodArgument must not be null!";
>
> rather than this -
>
> if (methodArgument == null)
>    throw new IllegalArgumentException("methodArgument must not be
> null!");
>
> Right?
>
> On Feb 11, 10:04 am, Paul Robinson <[email protected]> wrote:
>> It's because asserts are removed when compiled to javascript. Use
>> asserts for things that are so wrong that it's a programming error that
>> ought to be caught in development mode, and you don't want to pay any
>> overhead in production for it.
>>
>>
>>
>> Nathan Wells wrote:
>> > I've noticed that a lot of GWT code uses asserts rather than
>> > RuntimeExceptions (like IllegalArgumentException and
>> > IllegalStateException). I would go ahead an follow that template, but
>> > I want to be sure I understand why it's done. To that end:
>>
>> > 1) Are any other GWT developers using asserts rather than
>> > RuntimeExceptions?
>> > 2) If you answered "I do", why do you do it?
>> > 3) If there are any GWTers listening (perhaps I should cross-post to
>> > gwt-contrib?), is this a best practice recommended by GWT, or is it
>> > more of a stylistic thing?
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Google Web Toolkit" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to 
> [email protected].
> For more options, visit this group at 
> http://groups.google.com/group/google-web-toolkit?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.

Reply via email to