On Sep 28, 2013, at 10:59 , Max Leske <[email protected]> wrote:

> Thanks for the feedback guys.
> 
> Based on the discussion I propose a different set of changes:
> 
> 1.
> shuffle
>       ^ self shuffleBy: Random new
> 
> 2.
> shuffled
>       ^ self copy shuffle
> 
> 3. remove #shuffledBy: (if you're specific enough to use a custom Random 
> instance you can also create a copy of the collection yourself if you want to)
> 
> 
> I leave the matter of renaming the methods for further discussion. Personally 
> I'm for more intention revealing selectors; I quite like #shuffle and 
> #shuffleInPlace. If we can agree on a different naming scheme we should then 
> apply it to other methods aswell of course (e.g. #sort, #sortInPlace).
> 
> Also open for discussion is the use of Collection>>randomForPicking and 
> Collection>>mutexForPicking in other methods (such as #atRandom). I think it 
> shouldn't be too big a problem to make those methods use individual Random 
> instances and to remove the two class variables from Collection.
> 
> Cheers,
> Max

+1 from me on all three suggestions, as you might guess. :)

As for #atRandom using Random new, the performance hit and seed quality would 
be much greater concerns, as the Random instance would only be used once per 
invocation.
At this point in time there's no good alternatives to the current approach, but 
renaming the mutex/shared variable to reflect its singular use would be one 
possible improvement, I guess.

Cheers,
Henry

Attachment: signature.asc
Description: Message signed with OpenPGP using GPGMail

Reply via email to