Archive for “December, 2015”

Secret Santa Generator

It’s Christmas! And with Christmas comes Secret Santa! We replicated the names in a hat process which is normally used for this kind of thing: write all the names in pieces of paper and put them in a hat; each person takes one, if you drew your own name, you put it back and draw another. If the last person draws his own name, the whole process is repeated. We know it’s not the most efficient way to do it but is an interesting challenge to implement in PDI. You can find it here.

We start with a list of names and emails in a CSV file. PDI reads them, generates two sets of random numbers, builds the pairings and checks if in any pair there’s a repeated name. If so, it repeats the process again, until we have a valid list of pairs of names and then it emails everyone with the names of the recipient they were assigned.

Using loops in PDI is a powerful pattern but a dangerous one. One should always guarantee that the job will not loop indefinitely, eventually blowing up with an out of memory error. In our case this would happen if the list provided has only one name on it, but we trust the user not to misuse the program (besides, what’ the point of having a secret Santa if there’s only one Santa to assign, anyway?).