On Wed, May 13, 2015 at 12:25:25 +0100, Michael Rogers wrote:
> A few quick comments:
> 
> 1. You're calling a blocking method from the UI thread. Don't do that.
> Instead, call the blocking method on a background thread and post the
> results back to the UI thread when it returns. That's how the code I
> posted yesterday works. If you want to collect all the results before
> returning them, modify the listener interface to accept a list of
> clients, and collect the results on a background thread. You can use a
> CountDownLatch to wait for all the results to be returned.

Note that this is intentional and mentioned in the docs.

A CountDownLatch works much like calling invokeAll and iterating over
the futures, right? With the only difference that you're suggesting I do
that on a background thread.

The whole point of the blocking method is for it to be easier to use for
very basic use cases. If you don't want to block the UI thread, either
call this method on a separate thread or use the other method, which
doesn't wait for the results to be ready.

Perhaps I'm not using the best coding/interface practice for this, but I
think the overall idea is not wrong.

> 2. You have two methods for getting the reachable clients, but you're
> only calling one of them. If you're worried about verbosity, get rid of
> the unused method and interface. :-)

This is a library with an example app to show and test what it can do. I
don't think it is required that the example app use all the library
methods :)

> 3. You're declaring stuff final all over the place, which suggests you
> don't know which things need to be final. Try to work out which things
> need to be final and why, it will give you a better understanding of
> your code.

It's obvious that I'm no java expert. As far as I know final is useful
for stuff like attributes so that simple methods can be memoized. The
rest I simply don't know and couldn't find proper docs explaining why
or why not use final in each case, so I just went with the easy route of
using it by default.

Even though I'm not fond of this kind of verbosity - I wish that the
compiler did these kinds of optimisations without me having to use
"final". So suggestions welcome.

-- 
Daniel Martí - mv...@mvdan.cc - http://mvdan.cc/
PGP: A9DA 13CD F7A1 4ACD D3DE  E530 F4CA FFDB 4348 041C

Attachment: pgp8tHwtXlrGA.pgp
Description: PGP signature

_______________________________________________
List info: https://lists.mayfirst.org/mailman/listinfo/guardian-dev
To unsubscribe, email:  guardian-dev-unsubscr...@lists.mayfirst.org

Reply via email to