Explicitly and without apology a marketing vehicle MaryMaryQuiteContrary

Friday Oct 22, 2004



(or at least the first 35 of you)

check out what just moved across the JP wire:

SANTA CLARA (JP) -- As the US presidential race swings into high gear, a surprise newcomer has joined the ranks of the political front-runners -- Duke. Campaigning on a platform of recalling cost and complexity and eliminating the desktop tax, Duke is gaining significant support in the nation's must-win states.

Though a newcomer to the national political scene, Duke -- the lovable mascot of Java technology -- is the official candidate of the Java Everywhere party. He cut his political "teeth" in the California gubernatorial election where he mobilized an impressive grassroots organization.

His momentum in the presidential race is raising eyebrows in the war rooms of other mainstream candidates.

"We are closely monitoring developments," said one high ranking major party official who was quoted on the condition of anonymity.

Duke, who can trace his lineage directly to Dr. James Gosling, has been spotted on the campaign trail pressing the "flesh."

While the candidate is enjoying considerable momentum given his late entry into the race, his campaign is grappling with a high-profile controversy surrounding a radio ad that was created by a Sun Microsystems employee on company time.

The spot, which touts the freedom and momentum of the Java platform, is a thinly-veiled endorsement of Duke's presidential candidacy, detractors charge.

The Federal Election Commission is evaluating whether the spots violate the McCain-Feingold act.

Copy-all-right 2004 The Java Press. No rights reserved. This material may be published, broadcast, and redistributed

Can you even believe that?

It gets better.

I happen to have in my possession 35 Duke for President bumper stickers ...

picture of the bumper sticker on my car

... which I will send to the first 35 people who post a comment to this blog entry telling me why they are voting for Duke. (you don't have to be a US national to vote in this election ;-)

fun, fun, fun.

bon weekend!

mary

p.s. Friday Free Stuff is not a contest. it's me giving away stuff that I personally own to people I choose. I pay for shipping with stamps that i buy at the post office.

p.p.s. extra points (and probably extra stuff) if you listen to the radio ad and tell me how much you love it.

p.p.p.s. i love you too.

The Jacket!

We're giving away the jacket as part of this extra special MaryMaryQuiteContary Friday Free Stuff extravaganza!

You might recall that I personally love and adore Sun Certified professionals for Java technologies. In fact, I love Sun Certified professionals for Java technologies so much that I ponied up my brand new, never-been-worn, super specacular Java jacket to prove my love. In a "contest*" that I hosted, I invited all Sun Ceritifed professionals to tell me how being Sun Certified for Java Technology has saved their bacon; got them the job/raise; made them smarter; impressed the ladies (or gents) ;-)

Well, people the response was pretty staggering.

(You gotta read comments, people. There's so much that happens in the comments. It's the back room at the party where all the cool people hang out.)

And so, it is my great pleasure to award the jacket to Dave K, whose story about how being Sun Certified saved his house brought tears to my eyes (and made the rounds big-time on the internal email circuit). We reprint it here (without permission):

  • My Sun Java Certification saved my house! ...Seriously, it did!

    In April of 2002, I joined the ranks of the (far too) many computing professionals who suddenly found themselves out of a job when their employer realized the bubble they were riding on had popped. Being the sole income for the family, I was "a bit" stressed, however, I was still pretty upbeat because I had (what I thought were) marketable skills, an excellent work ethic, and well... dang it, I'm just cute.

    As you can probably guess, cute don't cut it in the real world. I spent five and a half months looking for a job and watching my bank account get smaller and smaller. Eventually, we got to the point that we decided to sell the house, move back to Nebraska and have my wife and kids live with my parents in the country while I sleep on my brother's couch in the city and look for work. My wife and I decided that on Friday we would talk to a realtor and put the house on the market. And then...

    Flashback: 2 months earlier.

    With my ego effectively reduced to the size of a tadpole, I started trying to figure out what "they" were looking for that I wasn't providing. I knew I interviewed well, but the problem was that I simply wasn't getting past the resume screening to even have a chance at the interview. I had heard that having a certification on your resume would NOT get you a job but it might get you an interview. Sounded like exactly what I needed.

    I immediately began studying for the Java Programmer certification and quickly found out that there was much more Java than I had yet run into. It still wasn't helping me in my job search but I felt like I was at least DOING something to make progress. Plus, I was actually learning... ...A LOT! Finally, after many I-haven't-studied-this-hard-since-college weeks, I felt I had filled in the critical gaps in my knowledge and took the leap to schedule the exam.

    The day of the exam came, and my days of NOT being Sun-certified went. I passed the exam and prepared myself to wade through the job offers that were due to start pouring in. When I walked out the front door, I found... ...no line of prospective employers waiting to swoop down on me and my certification. "Man, this economy is messed up. I guess I'll just have to..."

    Flashback: 2 weeks before Exam Day

    I had an interview for a contract Java position and really did well. During the interview, certification was mentioned in passing and I dropped in that I was scheduled to take the exam soon. After the interview, I was told that it was down to me and one other person and could expect to hear back soon. I checked back periodically (frequent enough to appear enthusiastic but not so frequent that I would appear deranged) but still got the same answer: it's a tie, nobody wins yet. Fine. I had studying to do anyway.

    Flash-forward: Newly-certified

    I called the company I had interviewed with and left a polite professional message wherein I calmly informed the hiring manager of my recent certification and carefully avoided using the word "Yippee!"

    Flash-forward: Wednesday (2 days before meeting with the realtor)

    The phone rang and I got offered the job! It was only a six-month contract, but it was enough to let us keep the house! Furthermore, on my first day working, my boss told me that the Java certification (and the fact that I called to let him know about it) was what pushed me into the lead and into the job.

    Since then, that six-month contract got extended to last 18 months and eventually became a permanent position with the company.

    So... My Sun certification helped me get a job that saved me from having to sell my house.

    But, even more important than all that, it made my daughter think I was really smart. :)

But wait, there's more!

We've got a second-runner-up prize! A voucher for any Sun Educational Services exam beginning with a 310 prefex. (value: a lot but i'm too busy to look it up right now).

It is my great pleasure to award this voucher to Kurt Magoon! Kurt won the judges (me) over with his "almost zealot-like" affinity for Java.

  • Mary,

    I've been a software developer for over 15 years and written programs in many different computer languages. Back in 2000, my project team decided to develop a new application using Java (Swing) for the user interface and J2EE for our server components. I learned and enjoyed working with Java and writing Swing UIs. After a while, my team leader complained that I had pigeonholed myself as "just" a Swing developer. I did two things in the spring of 2002 in attempt to appease him. I got him to send me to JavaOne to help understand all of the different forms of the Java platform and I studied for and passed my Sun Certified Programmer for the Java 2 platform exam.

    Although I was initially trying to get my team leader off my back, those two events changed my view of the Java platform. I became excited about the language and the platform. I was amazed at all the things that could be done in Java. Studying for the test allowed me to obtain an understanding of the language that bled over into the day-to-day project work developing both Swing and J2EE components. I was able to help out co-workers with language questions.

    Did becoming “certified” help me get onto some better projects? I believe so. Did having it on my resume when I switched jobs help? It probably did. More importantly, I developed an almost zealot-like affinity for Java. I now seek out information about how Java is being used and how I can use.

But wait, there's even more.

Everybody else gets a t-shirt! (Yes, of course you too, Luke). Everybody except for Michael. Because I just gave Michael a t-shirt minutes agao for being so smart (see previous blog entry). So Michael gets a Sun Developer Network hat. (in addition to his previously won t-shirt).

And soooooo...... if you're one of my lucky winners (and you know who you are), send me email using the following formula: first.last@sun.com. firstname: mary; lastname:smaragdis. i need your mailing address. copy it down so that i can send you the free stuff. i won't use your personal info for any other purpose whatsoeve.r i won't share it. i'll delete the mail after i've copied it down

And if you can even believe this, there is even more to come as this special MaryMaryQuiteContrary Friday Free Stuff Extravaganza continues! Stay tuned...

mary

p.s. i think i'm starting to feel a little love for Sun Certified for Solaris professionals... just a vauge aching deep within.. who knows how that will manifest iteslef ;-)

p.p.s. i reserve the right to substitue the t-shirt with some other nice prize. because i didn't actually count to make sure i've got enough t-shirts. super busy. no time.

*i don't do contests. i use the word euphemistically. what's happening here is that i am personally giving away something that i personally own to somebody i personally choose. in this case, it's a very special Sun Certified professional somebody.  i pay for shipping with stamps that i personally buy at the post office.

The Friday Free Stuff extravaganza is about to begin.

first installment: the solution to last week's puzzler which comes to us straight from the personal (!) email accounts of techno celebs extraordinarie(s) Dr. Josh Bloch and Dr. Neal Gafter:

In last week's puzzler, you were given a library class:

public class Foo { 
   public Foo(int i) {
       ...;
   }
   ...
}

Because it's a library class, you have no access to its internals and you can't modify it. Suppose you want to write a subclass:

public class Bar extends Foo {
   private final int j;

   public Bar() {
       super(j = SomeOtherClass.f());
       ...
   }
}

Unfortunately this isn't legal. If you try it, you'll get this error message:

Bar.java:13: cannot reference j before supertype constructor has been called
       super(j = SomeOtherClass.f());
             ^

You were asked to refactor the program to achieve the desired effect, subject to the following constraints:

  1. Class Foo does not have an accessor to return i.
  2. You can't call SomeOtherClass.f() twice, as there is no guarantee that successive calls will return the same value.
  3. Your program must be thread-safe: multiple threads may invoke the constructor Bar() concurrently.
  4. Elegance counts.
  5. Don't code like my brother.

You did very well indeed! The winner was Chris Nokleberg who posted a correct, complete, elegant solution 26 minutes after Mary posted the problem. Twenty-six minutes! Can you believe it?

The basic idea of Chris's solution was to interpose a private constructor in between the public parameterless constructor and the superclass constructor

public class Bar extends Foo {
    private final int j;

    public Bar() {
        this(SomeOtherClass.f());
    }

    private Bar(int f) {
        super(f);
        j = f;
    }
}

This is exactly the solution that we were looking for. It's easy if you see it, impossible if you don't.

Second place goes to Michael Nascimento Santos, who came up with the following solution, in which the result of invoking SomeOtherClass.f() is stashed in a static thread-local variable prior to invoking the superclass constructor. The value can then be copied into the instance variable after the superclass constructor is invoked:

public class Bar extends Foo {
   private static class ThreadLocalCachedValue {
      private final ThreadLocal threadLocal = new ThreadLocal();

      public int setValue(int value) {
         threadLocal.set(new Integer(value));
         return value;
      }

      public int getValue() {
         return ((Integer)threadLocal.get()).intValue();
      }
   };

   private static ThreadLocalCachedValue cachedValue =
         new ThreadLocalCachedValue();
   private final int j;

   public Bar() {
      super(cachedValue.setValue(SomeOtherClass.f()));

      j = cachedValue.getValue();
   }
}

Michael submitted his solution a mere eight minutes after Chris. You guys are unbelievably fast! Michael's solution was, however, less elegant than Chris's. Kris Schneider submitted a similar solution to Michael's that avoided the use of a nested class by wrapping the ThreadLocal.set call in a static method on Bar. The ThreadLocal solution can be made a bit more elegant by using the new ThreadLocal.remove method added in JDK 5:

public class Bar extends Foo {
    private final int j;

    private static ThreadLocal<Integer> sleaze = new ThreadLocal<Integer>() {
        protected Integer initialValue() {
            return SomeOtherClass.f();
        }
    };

    public Bar() {
        super(sleaze.get());
        j = sleaze.get();
        sleaze.remove();
    }
}

This solution is still a good deal less elegant than Chris's. There's a reason we called the ThreadLocal variable sleaze.

A crate of rotten halibut goes to Ron Yang and Ka-Hing Cheung, who didn't check to see whether their programs compiled before posting them. Hint: they don't.

Tom Hawtin proposed a solution wherein he interposed a class between Foo and Bar, and stashed the results of SomeOtherClass.f() in an instance variable of the enclosing class. This works, but arguably it violates the conditions of the problem. Similarly, Tom proposed the use of a static factory, but the problem states (albeit subtly) that Bar must have a public parameterless constructor. Normally we're big fans of static factories, but occasionally you don't have that option. Sometimes you need your class to be extendable. The same restriction rules out Tom's inner-class based solution. However, Tom gets an honorable mention for submitting three (!) solutions.

Bob Lee corectly points out that if you're writing JVM byte code rather than Java source code, you can simply set the instance variable before invoking the superclass constructor. This is, in fact, how the compiler initializes the enclosing-instance field for instances on non-static nested classes.

Nikita Tovstoles submitted a convoluted by correct solution in which a single static variable was used to stash the results of SomeOtherClass.f() as the superclass constructor was executed. Hairy synchronization code was required to make it work in the presence of concurrency. Click and Hack characterize this solution as ingenious-but-yucky.

So the big prize package...

... goes to Chris Nokleberg!

But wait, there's more.... Michael, Kris, Tom, Bob and Nikita all get t-shirts because Click and Hack said nice stuff (to varrying degrees) about each of you!!!

If you end up looking as cute in your t-shirt as Vanessa does...

... send me a picture and maybe I'll post it.

Ron and Ka-Hing: if I had any rotten halibut I'd send it to you. Lucky for you I'm fresh out.

So that closes out last week's puzzler. But we're not done yet. More Friday Free Stuff is on your way as this MaryMaryQuiteContary special Friday extravaganza continues... stay tuned.

:-)

mary

p.s. bookmark. shift. reload.

p.p.s. i kindly ask that you lucky winners send me email with your mailing address using the following formula: first.last@sun.com. my firstname is mary. my lastname is smaragdis. i will use your personal info for the singular purpose of copying it down onto an envelope (or in Chris' case, a box) so that I can send you the free stuff. I won't share your personal info with anybody. I won't use it for any other purpose whatsoever. After I copy it down I'll delete the mail.

p.p.p.s. Don't get any ideas about impersonating a winner, people. It won't work. And if you try I will black list you.