PEAT Online Course -
Test-Driven Development
using Kotlin (DELUXE EDITION)

  • Theory 'n' practice
  • Test-driven method
  • Acceptance criteria
  • Learn to code mastery
  • Ace that job interview
  • Free updates
AVAILABLE NOW
VIMEO ON-DEMAND

The Competition Winners of the Java EE 7 Developer Handbook

29 November 2013 Comments off

5 minutes

981

There are 3 lucky winners of the Java EE 7 Developer Handbook competition.

Congratulations to Cathy White, the special selected winner, who wrote the best comment and wins first prize!

The next two winners in second and third place, respectively, are Rui Morais and Seb Rose. They were chosen by this following Groovy program that randomly shuffles a list collection of elements:

// LICENCE is GPL 3.0 (GNU PUBLIC LICENSE 3.0)
// Peter Pilgrim, Xenonique.co.uk
package uk.co.xenonique.je7hb.competition

import java.security.SecureRandom

/**
 * The type JE7HBLottoTest
 *
 * @author Peter Pilgrim
 */
class JE7HBLottoTest extends GroovyTestCase {

    List entrants = [
    /* SPECIALLY SELECTED WINNER FOR BEST REPLY COMMENT
     "Cathy White, @athyC, 21 Nov, Learning Java EE7
    so I can use existing Java code to build a robust, scalable,
    modern system with a great web UI #javaee7handbook", */

    "Himadri Pant ,?@himadripant, 21 Nov, JEE 7 packs a powerpunch of " +
            "Project Coin and other features of Java 7. Hopeful of " +
            "getting this master guide into JEE 7 #javaee7handbook.",

    "IanonP, ?@iPolding, 20 Nov, Being so new to development, the " +
            "#javaee7handbook sounds like just what I need to " +
            "kickstart my new career",

    "Seb Rose, , 14 Nov, It has been a long time since I immersed " +
            "myself in EE Java. This book will give me the information " +
            "I need in a format I can use. I know this because I am a " +
            "long time reader of Peter's work. " +
            "If I don't win this book, I'll buy it anyway!",

    "Mohan Radhakrishnan, , 14 Nov, I have been following your blog for " +
            "several years.The stress on communication and " +
            "presentation skills is what attracts me most.",

    "Harmeet Singh, , 10 Nov, #javaee7handbook I am new in JavaEE " +
            "and so, i want to learn JavaEE new technologies and " +
            "i am still wait for Java 8. The future plan for " +
            "JavaEE 8 is really good. The Arun Gupta Articles " +
            "are amazing for J2EE 7.",

    "Andrew Bell, ,  17 Nov, I'm a recent college graduate " +
            "(read poor) and new Java developer trying to suck up " +
            "all the information I can!",

    "José antonio, , 18 Nov, IMHO JEE 7 brings new fantastic " +
            "features like Websockets and JSON to just name a few " +
            "and I'd like to learn it to be a java top developer",

    "Vivek Krishnan, , 19 Nov, #javaee7handbook Make it my birthday gift :D",

    "Mariano Eloy Fernández Osca , , 19 Nov, JEE has been moving forward " +
            "so fast the last couples of years ... curated information " +
            "is so valuable when there's so much ground to " +
            "cover. Hail #javaee7handbook.",

    "suresh, , 19 Nov, very much interested in understanding the" +
            " support for PAAS in Java EE 7. Its inclusive support " +
            "for jpa 2.1 and JAX-RS 2.0.",

    "Rui Morais, , 19 Nov, This would be perfect to revamp my Java " +
            "EE knowledge!!",

    "Daniela, , 19 Nov, what a nice book to read! (my bday is on friday... 😛 )",

    "Carsten Cerny, , 19 Nov, Hallo, ich kann leider nicht zur " +
            "Konferenz kommen. Würde das Buch aber trotzdem gerne lesen."

    /* (Duplicate) "Himadri Pant, , 19 Nov, JEE 7 packs a power punch of
    Project Coin and other features of Java 7 into the enterprise edition.
    I am hopeful of getting this master guide into JEE 7." */
    ]

    void testPickRandomWinners() {

        warmUpTheJVM();
        def N = entrants.size()

        SecureRandom secureRandom = new SecureRandom();
        for ( int j=0; j<Math.abs(secureRandom.nextDouble()) * 32678 + 16384; ++j ) {
            Collections.shuffle(entrants)
            assertEquals( N, entrants.size() )
        }

        println( "First winner is ${entrants[0]}\n")

        println( "Second winner is ${entrants[1]}\n")

        println( "Third winner is ${entrants[2]}\n")
        println( "Fourth winner is ${entrants[3]}\n")
        println( "Fifth winner is ${entrants[4]}\n")
    }

    final private static int MIN_NUM = 12;
    final private static int MAX_NUM = 25;

    private static void warmUpTheJVM() {
        SecureRandom secureRandom = new SecureRandom();
        Random rnd = new Random(System.currentTimeMillis());
        for (int j=0; j<Math.abs(secureRandom.nextDouble()) * 1048576 + 524288; ++j ) {
            calcFibonacci((int)(Math.abs(secureRandom.nextDouble()) * (MAX_NUM - MIN_NUM)) + MIN_NUM);
        }
    }

    private static int calcFibonacci(int n) {
        int result = 1;
        int previous = -1;
        int sum = 0;
        for(int i = 0; i <= n; i++) {
            sum = previous + result;
            previous = result;
            result = sum;
        }
        return result;
    }

}

But it doesn’t just shuffle a list, I  copied the blog comments and the Twitter #javaee7handbooks tag entries into a Groovy list. The tricky part was being fair and smart. I wanted to be fair and generate a good random selection of winners. When the program first runs, it warms up the JVM. I also used a javax.secure.SecureRandom object instead of the mathematically crackable PRG implementation java.util.Random.

After ensure the program actually did what it was supposed to, I ran a few iterations , capture a definitive sample to the standard output:

First winner is Rui Morais, , 19 Nov, This would be perfect to revamp my Java EE knowledge!!

Second winner is Seb Rose, , 14 Nov, It has been a long time since I immersed myself in EE Java. This book will give me the information I need in a format I can use. I know this because I am a long time reader of Peter's work. If I don't win this book, I'll buy it anyway!

Third winner is Carsten Cerny, , 19 Nov, Hallo, ich kann leider nicht zur Konferenz kommen. Würde das Buch aber trotzdem gerne lesen.

Fourth winner is Vivek Krishnan, , 19 Nov, #javaee7handbook Make it my birthday gift 😀

Fifth winner is Daniela, , 19 Nov, what a nice book to read! (my bday is on friday... 😛 )

From output, Cathy White was already excluded from the list collection.

Congratulations to all the winners, enjoy your e-book, and to the other contestants, thanks for entering the competition.

+PP+

Hey all! Thanks for visiting. I provide fringe benefits to interested readers: checkout consultancy, training or mentorship Please make enquiries by email or
call +44 (0)7397 067 658.

Due to the Off-Payroll Working plan for the UK government, I am enforcing stricter measures on contracts. All potential public sector GOV.UK contracts engagements must be approved by QDOS and/or SJD Accounting. Please enquire for further information.