InfoQ.com Top Posts of 2008

Posted in Jon Rose on December 31st, 2008 by jonr

jonr originally posted this on Jon Rose's Blog.

In 2007, I became an editor for InfoQ.com.  InfoQ.com is an enterprise software development community, with news, articles, video interviews, and a yearly conference.  As an editor, I write weekly news items and contribute the occasional article or video interview.

Today we posted a list of the Top Posts of 2008.  I am excited to have a few items on the list.  I had the number one item in the architecture community, a news post titled “James Gosling on Adobe Flash / Flex / AIR.“  In the Java community, I posted 2 of the top 5!  Both of these posts are original works that I collaborated on with James Ward (Top 10 Adobe Flex Misconceptions & Top 10 Mistakes when building Flex Applications).

Click through and check out all the exciting 2008 news!

Hibernate and EnhancerByCGLIB issues

Posted in Bob Hedlund on December 30th, 2008 by admin

admin originally posted this on Eldorado Software.

Working with Hibernate can make performing routine database operations a breeze. Every now and then however you hit a snag that causes your brain to drop on the floor. I recently ran across one of these situations where objects were not being updated. After checking my syntax and inspecting objects, I realized the issue had to do with the fact that Hibernate will often create proxy objects as classes of type EnhancerByCGLIB when pulling collections that are marked as FetchType.LAZY. It also occurs when the SessionFactory is asked to load() the object instead of get().


First Case : Lazy Initialization Proxies:

The proxies may often contain all the information in your persistent class, and so they appear to be the real deal. When we query these objects they return all the information in the underlying proxied object. We run into a couple issues however if we use standard implementations of equals in our persistent class:

Lets say your equals() method in the class Noodle looks like this:

public boolean equals(Object obj) {
if(this == obj)
return true;
if(getClass() != obj.getClass() )
return false;
........
}


At this point we see that equals will never succeed - the class Noodle will never equal the Hibernate Proxy class. When you try to update an object from the collection, Hibernate never finds the object it needs to update because the equals implementation always fails. If you need to implement a comparison of class you could use one of the following :

this.getClass().isAssignableFrom(obj.getClass())

or

HibernateProxyHelper.getClassWithoutInitializingProxy(obj)

If you use hibernate annotations in your pojos, this additional Hibernate checking should not be too invasive or out of place. One other mistake people often make when implementing equals is to try to access the fields directly off of the object:


public boolean equals(Object obj) {
....
Noodle other = (Noodle)obj;
if(! this.attributeA.equals(other.attributeA) )
return false;
....
}


Here we run into 2 issues:

1. The cast may throw a ClassCastException.
2. The attributeA may have limited visibility.

A Solution that worked for me and covers the situation where the other object is not a proxy:

public boolean equals(Object other) {

if ( this == obj )
return true;

if( obj == null )
return false;

if( getClass().equals( obj.getClass() ) {
Noodle other = (Noodle)obj;
if( getId().equals( other.getId() )
return true;
}

else if( obj instanceof HibernateProxy ) {
if(HibernateProxyHelper.getClassWithoutInitializingProxy(obj).equals(this.getClass() ) {
Noodle other = (Noolde)obj;
if( getId().equals( other.getId() )
return true;
}
}

return false;
}

Second Case: You used Load() instead of get():

There may be times when you want to use load() - when you are simply adding references to an object in a collection for instance. But when you are pulling an object specifically to use its values, you should switch to using get() - as the attributes are guaranteed to be available.


Flex Book for Beginners

Posted in Jon Rose on December 23rd, 2008 by jonr

jonr originally posted this on Jon Rose's Blog.

If you are new to Flex, or just curious about it, you need to check out James Ward (my Drunk On Software partner) and Bruce Eckel’s book, First Steps in Flex.

Apple Rocks!

Posted in Jon Rose on December 23rd, 2008 by jonr

jonr originally posted this on Jon Rose's Blog.

I spent Friday afternoon telling my friend Wes that I have never lost a hard drive that wasn’t in a Raid 5 / NAS… Thus, my Mac hard drive failed Saturday afternoon.  Amazing?!?!

Anyhow, I couldn’t be more impressed with Apple.  I put in a support request online and was called with in seconds of hitting the submit button.  I was unable to resolve it on the phone, but was able to schedule and appointment for 2 hours later at the Cherry Creek Mac store.  Luckily for me, Stu has recently had a hard drive die on him.  So, I had purchased my Time Capsule and been regularly backing up to it.  They quickly determined that the drive was dead and put in a new one.  After only a few hours at home, I was able to restore from the Time Capsule and I am back up and running with all of my files intact…. After years of owning PC’s, I couldn’t be more impressed.

Even better, was seeing Peter Forsberg in the Mac store while I was waiting.  I cannot imagine losing a hard driving ending up better…………

Gorilla Logic builds NBC iCue’s first Facebook application..

Posted in Gorilla Logic on December 22nd, 2008 by admin

NBC’s iCue recently got social on Facebook by launching their first ever Facebook application. It leverages NBC’s vast news content in a trivia type game for all ages. You can find one of many articles on the topic here.

Gorilla Logic was the company that NBC tapped to build the Facebook application, however that isn’t mentioned in the article. Oh well, that’s how the banana peels sometimes.
If you’re on Facebook, download the app here and check it out! It’s actually pretty cool. If you’re not on Facebook….. Why not?
Thanks for reading.

Episode 5: Devoxx, Parleys.com, and RIA Frameworks

Posted in Drunk On Software on December 15th, 2008 by admin

admin originally posted this on Drunk on Software.

In this episode we talk with another Drunk on Software favorite, Stephan Janssen. Stephan is the founder the Devoxx conference (formerly JavaPolis) held annually in Belgium. Devoxx is currently the second largest Java conference, behind only JavaOne. In addition to his work on the Devoxx conference, Stephan is the founder and lead engineer of Parleys.com. Parleys is a RIA platform for delivering online learning resources, such as videos, podcasts, slides, etc.

We caught-up with Stephan at the QCon conference in San Francisco, where he was speaking on RIA in the real world. In the episode we talk about Devoxx, Parleys, and the current state of the RIA world.

Once again, we switched to flip.tv for the video hosting. You can now subscribe to the podcast feed in iTunes using the URL: itpc://drunkonsoftware.blip.tv/rss/itunes/
Or to the show RSS using the URL:
http://drunkonsoftware.blip.tv/rss

Moe, Larry, and Curly Braces

Posted in Stu Stern on December 11th, 2008 by Stu Stern

Stu Stern originally posted this on Big Gorilla - Stu Stern's Blog.

We've thus far discussed several of the primary pillars of Precision Modeling -- derivation expressions, conditional expressions, query expressions, and derived associations -- and we've used these to help out our hypothetical (and some might say homicidal) customer, arms4less.com ("where you can get regime change for small change!"). We've been specifying the business rule stating that customers' can pay a surcharge to prevent their enemies from purchasing any of the same weapons they're purchasing themselves. We did this by creating a derived association, enemyProducts, that contains the list of all products we are unable to sell to a particular customer, because they have already been purchased by enemies of the customer who have opted to pay the surcharge:

/enemyProducts : Product = enemies.orders.items[isExclusive].product


Now we just need to somehow use this association to prevent a customer from actually buying any of these enemyProducts. As with the many wonders of Precision Modeling we've previously discussed, we can specify such a requirement precisely and concisely (Hey, that rhymes. Our marketing people will be so pleased.) via a little Gorilla UML.

Notice the constraint expression we've attached to OrderItem:

{not product in order.customer.enemyProducts}

In UML, constraints are specified inside curly braces (many have postulated this proves once and for all that Grady Booch is a die-hard Three Stooges fan). Because this constraint is attached to OrderItem, it is specifying that any product associated with an OrderItem cannot also be included in the list of the order's customer's enemyProduct's list.

Our SME, Sarge, inquires as to how we plan to enforce this constraint? "If it gets violated, there needs to be -- you know -- consquences." We ensure him that we will be sure to thoroughly test our implementation of this constraint to ensure that the software indeed enforces it. Sarge sighs wistully as he removes his hand from a bulge beneath his flack jacket.

Episode 4 – When I am King

Posted in Drunk On Software on December 8th, 2008 by admin

admin originally posted this on Drunk on Software.

In this episode we chat with Chet Haase from the Adobe Flex SDK team. In his spare time Chet entertains and educates many with his humor blog, his recently released book “When I am King“, and a technical book about Swing co-authored with Romain Guy called “Filthy Rich Clients“.

Here’s the episode. Let us know what you think.

BTW: We’ve switch to flip.tv for the video hosting. You can now subscribe to the podcast feed in iTunes using the URL:
itpc://drunkonsoftware.blip.tv/rss/itunes/
Or to the show RSS using the URL:
http://drunkonsoftware.blip.tv/rss

Notes from a Windows to Mac Conversion Bender

Posted in Bob Hedlund on December 8th, 2008 by admin

admin originally posted this on Eldorado Software.

I recently upgraded from my 2 year old pc to a new mac book pro. It was a tough decision because I need to be able to run oracle and the customer I am working with uses WebEx AIM Pro for desktop sharing. (I work remotely 75% of the time.) . The final decision to go mac was heavily influenced by the fact that I could use vmware to run an instance of my windows pc on the mac. The fear of Vista (Vistanoia?), the desire to leave the world of waiting for apps to respond, and the chance to try out a new toy were beckoning.

I pulled the trigger, and jumped on the configuration express.

I've been in config-hell before, and something deep down told me this would be no different. All the smiling faces that I met saying that changing to a mac was like a trip to disney surely had to have an unseemly downside lurking in a hidden log file.

The basic setup was pleasant - eclipse and tomcat installed as on a pc by simply unzipping them into the directory where they would be run from:

%> sudo gunzip apache-tomcat-5.5
%>sudo tar -xvf apache-tomcat-5.5
%>cd apache-tomcat-5.5/bin
%>./startup.sh (You are now running tomcat)

Eclipse was similiar.

One thing to get used to on a mac is that you no longer download jdks from sun. The jdk is preinstalled on your machine. You go to the Apple site and download the jdk for the mac if you need a different version or need an update. Apple doesnt seem to supply options for minor versions.

I ordered up a copy of VMWare fusion and planned to install my old pc on the mac as a resource - the ability to access old email, documents etc without having to go back to an old machine. However I had overlooked one issue - the windows xp had been installed on my pc when I bought it, and when I booted it up on the vmware, windows insisted on an activation key. The old one on the laptop was no longer valid, and so I had three days of use before the activation grace period expired. In that time I copied files over to the mac and made the most of the situation. The VMWare fusion worked greeat - and it was phenomenal to see the old pc running on the mac.

I would suggest taking snapshots of your OS in vmware, and make sure you keep the original so that you can always return to it. After three days however, I said goodbye to my old pc on the mac.

The next step for me was to get Oracle installed on the Mac. This was simple enough by installing Ubuntu on a vm in the vmware fusion. Again, vmware worked like a charm and Ubuntu is a very nice and user friendly. I used Ubuntu 8.10 and downloaded an OracleXE database. Everything went smoothly, and the database runs without issue. With vmware I can actually drag and drop files between desktops, and the database has been running without issue.


On Ubuntu, before you start running all over the net looking for apps or jdks to download, use the Synaptic Package Manager under the System tab on your desktop. Real simple.

The stumbling block for me was that the project I work on uses sqlldr to load the database. This executable processes a flat file and inserts the data in the oracle database based on a template definition. I wanted to run the eclipse and tomcat on the mac, and the oracle instance on the Ubuntu vm. I read that installing the oracle client on the mac was possible, but when I did, I found that it did not come with the sqlldr utility.

My first plan to circumvent the issue ws to run eclipse and tomcat on the Ubuntu instance. This worked, but eclipse had issues - perspectives needed to be configured with each new restart, and I found eclipse crashed in the vm frequently. I needed an environment that was stable and able to handle heavy loads on the processor and manage the memory well. This was not the case on Ubuntu in the vmware virtual machine.

The next idea was to install A Samba server on Ubuntu. Samba allows you to access other machines, in this case the virtual machine on my mac. The install call was

%> sudo apt-get install samba smbfs

This allowed me to access files across machines - however I was not able to execute the sqlldr command from the mac on the Ubuntu machine.

My next plan of attack is to update to the OS/X Server and install the Oracle Client for 10g.

And so it goes...









Slice and Dice

Posted in Justin Shacklette on December 7th, 2008 by admin

admin originally posted this on Saturnboy.

The design from the last post is finished, and it follows a very simple blog layout. In this post, I’ll slice the design and turn it into a pretty html page with the magic of Blueprint CSS.

Slice It

Before we get slice happy, we need to think. First, Blueprint is grid-based, so that means rectangles are good. And second, the default Blueprint container width is 950px. The defaults are intelligently chosen and have always worked great for me. By sticking with the defaults, we will get a 950px wide, centered, fixed-width site, which is exactly what we want.

We could get all clever and try to slice out just the circles as a background image, but that would force the top border to be a transparent PNG because of the shadow. Similarly, we could cut out all four rounded corners and all four edges of the sidebar, but that would force us to reassemble humpty dumpty with some fancy css and markup. In both cases, just say No! The simplest possible choice is to slice the entire header, the entire footer, and then a thin slice for the body that can be vertically tiled. Exactly like this:

slice diagram

And we get: the header, the background tile, and the footer. Slicing the sidebar in the exact same manner gives: sidebar header, sidebar background tile, and sidebar footer.

Code It

The original simple blog layout had four divs: header, content, sidebar, and footer. This is exactly want we want, but the original markup won’t exactly work, because the current design has a vertically-tiled background. The solution is simple – just wrap the content and sidebar inside a div with a bit of padding (via a prepend-2 and append-2). If we ignore the sidebar design for a moment, and just insert a placeholder, the markup is:

<div class="container">
  <div id="header" class="span-24">header</div>
 
  <div id="bg" class="prepend-2 span-20 append-2">
    <div id="content" class="span-15">content</div>
    <div id="sidebar" class="span-5 last">sidebar</div>
  </div>
 
  <div id="footer" class="span-24">footer</div>
</div>

That’s just beautiful Blueprint markup! Adding some simple css:

body {
background-color:#111;
}
 
#header {
background:#111 url(img/circ-head.png) 0 0 no-repeat;
height:160px;
min-height:160px;
}
 
#footer {
background:#111 url(img/circ-foot.png) 0 0 no-repeat;
height:30px;
min-height:30px;
text-align:center;
}
 
#bg {
background:#fff url(img/circ-bg.png) 0 0 repeat-y;
}

And that gives us Circles of Doom, version 0! View it, or download it. I’ve included the latest-and-greatest Blueprint CSS, which is v0.8 at the time of writing. I’ve chosen to enforce the vertical height of the header and footer via height and min-height which seems to work fine in Firefox, Safari, and IE7.

Sidebar Me

Since the sidebar graphic was sliced in the exact same manner as the body graphic, we just add the exact same markup to the sidebar div – header, bg, and footer.

<div id="sidebar" class="span-5 last">
  <div id="sidehead" class="span-5"><!-- sidebar header --></div>
  <div id="sidebg" class="span-5">sidebar content</div>
  <div id="sidefoot" class="span-5"><!-- sidebar footer --></div>
</div>

Style it like this:

#sidehead {
background:transparent url(img/sidebar-head.png) 0 0 no-repeat;
height:14px;
min-height:14px;
}
 
#sidefoot {
background:transparent url(img/sidebar-foot.png) 0 0 no-repeat;
height:14px;
min-height:14px;
}
 
#sidebg {
background:transparent url(img/sidebar-bg.png) 0 0 repeat-y;
}

Putting everything together with some dummy Lorem Ipsum text gives us Circles of Doom, version 1! View it, or download it.

Debug It

Lorem Ipsum text is the basic unit testing for HTML+CSS. I always fill out every content div with some dummy text, just to see what breaks. This time around, I noticed the sidebar content was touching the edges. I decided against adding a prepend-1 and append-1 because that’s too much padding. Instead, I thought I might just add some padding to sidebg, but this is bad, bad, bad! You can not add padding or margins to a Blueprint node, which sidebg clearly is because of the class="span-5". I could add another div inside sidebg, but that seemed like too much markup. So, I took the easy way out and just padded the known sidebar content markup (in this case, just p and h3).

#sidebar h3, #sidebar p {
color:#fff;
padding:0 10px;
}

Digging Deeper: Blueprint CSS uses margin and padding to create the grid. Thus it should have been obvious to me that you can NOT add margins or padding to a Blueprint element (any markup element with a Blueprint grid class). Alas, it was not immediately obvious, but I was able to catch my mistake during debugging.

And that’s it for the visual aspect of Circles of Doom. Next, I’ll cover web design optimization.

The Files