This weekend, we decided to take our daughter to her first movie in a real theater. This was the first time my and I had set foot into a movie theater in about three years (Yeah, we haven’t been out to see a movie since she was born). Sadly, we quickly realized that we haven’t missed much as all.

If memory serves me correctly, the Lowes at the Loop is actually a relatively decent theater. At least, three years ago anyway. First off all, all you can smell is the stench of pop corn. Second, the volume in the theater is simply way too loud. For a movie like Madagascar, there’s no need for it to be that loud. The child of mine simply did not approve. Lastly, the picture quality sucked! It didn’t help that they had technical issues with the projector which delayed the showing for 15 minutes. Once the lights dimmed and movie started, the color was just dull and washed out. Add to that the screen is smeared with candy and whatever other crap people throw at it. It was just a very unpleasant experience that ruined a decent movie and we had to leave half-way through because it just too damn loud.

The funny thing is that I think we have a much more enjoyable experience at home. I only have a 37-inch Sony Bravia XBR-6 coupled with a Sony BDP-S350 Blu-ray player. With just the TV and Blu-ray player alone, I’d say that the viewing experience is already better better than what we had at the Lowes. The family opinion is that the picture quality on the “teenie” 37-inch screen is far better than what we saw at the Lowes. Plus, there’s no funk on the screen. And the best part is that we have it all to ourselves without people on cell phones, etc.! While it’s true that a Blu-ray is more expensive than a DVD, prices are coming down. But when you consider that that two adult tickets cost $20, it makes the Blu-ray price pretty attractive. Anyway, my wife and I are pretty sure that movies will be viewed at home from this point forward, because yes, Blu-ray is that good.

You know, a lot of network T.V. kinda sucks so when a decent show comes along that goes on the chopping block, it bums me out a bit. I started watching Life on NBC just because I happened to be watching NBC at 10pm ona Wednesday and it happened to be on. I didn’t plan on watching it, but I was taken in quite quickly. Season 1 was amusing but cut short due to the writers strike.  It was a quirky enough show that I decided to give it another look this year. 

Given the fact that Life started on a Friday night schedule had me concerned that NBC didn’t have high hopes for the show. Thankfully, NBC picked up a full season and moved the show back to Wednesday. So far this season, the writing and acting are so much better and the story lines are even quirkier. The show also go an addition humor boost with the addition of Donal Logue (a.k.a Jimmy the Cab Driver). The show has even got my wife hooked and it’s now DVR’d every week. Furthermore, I find myself watching Life episodes more than Heroes at the moment.

But now I hear that NBC is giving Jay Leno the 10pm time-slot for each day of the week. Unfortunately, Life  is one of those shows at risk in 2009, as are some other shows. Balls! Anyway, there’s certainly better things I can do than whine about a T.V. show, given the awesome weather we’ve been having here in the northeast.

Two years ago, I raised a few points about some of the short comings of SWT. Because of it’s native bindings, SWT makes the Java mantra of “write once, run anywhere” quite a bit more daunting. For the most part, SWT’s cross-platform support is actually quite good and it is a decent in terms of performance. And, if weren’t for SWT’s existence, we probably wouldn’t have seen Sun address Swing’s performance issues like they did in Java 6. Unfortunately, when a minority platform like OS X makes some steep architectural changes, SWT-based applications end up with more work on thier hands.

As most folks know, Java 6 on Mac OS X 10.5 was a long time coming. It took Apple over a full year after the initial release of Java 6 to get it running on Mac OS X. Now that it’s here and working pretty much “ok”, I decided it was time to start running Java 6 as my default JVM. Then the surprise: Eclipse won’t run under Java 6 on the Mac. Why? Because Java 6 under Leopard is 64-bit. The current version of SWT on OS X relies on Carbon, which is 32-bit and we won’t be seeing 64-bit Carbon anytime soon. Support for 32-bit Cocoa is planned for later next year, but I didn’t see word on when 64-bit Cocoa or even just Java 6 support might arrive.

Eclipse is still a great IDE even if I have to continue to run it under Java 5. However, this is one of those things that is annoying each time a platform needs to make significant changes. But this time, you can’t put all of the blame on the Eclipse crew. Apple did an absolutely terrible job keeping the Java community abreast of what thier plans were with Java 6. In fact, it almost seemed that Java 6 would never appear on Leaopard. Coupled with the fact that Java 6 was now going to be only 64-bit and Carbon was not goning to see 64-bit support. But long story short, SWT and therefore Eclipse is always going to be hindered by OS changes to a greater degree than say NetBeans or IDEA.

It’s always annoying to upgrade WordPress and then to find out 2 days later that all of your links now return a 404 error. All this depsite the fact that it was all working just fine after the update. It turns out there seemed to be some kind of global change my hosting providers mod_rewrite rules which, in turn caused the links to fail. Thankfully, I was able to correct it by adding a revised .htaccess file. It’s trivial but also disturbing seeing as how I didn’t need maintain a separate .htaccess until now.

Did you ever have that teacher or professor who always tried to tell you that: “there is no such thing as a stupid question?” This may have been true in school, but in a professional software engineering environment, I can confidently tell you there are some really dumb questions being asked. Before I rant on, I’ll qualify this further by saying the majority of these questions are not stupid because people are utter morons, but because people are either completely lazy or don’t know how to compose a question to get the answers they seek.

No doubt business and project management folks ask questions that you may want to categorize as dumb or stupid. However, most of these folks aren’t as technical as you, and the questions maybe hilarious at times. My personal favorite:

“So, do you use pixels because some people don’t have fonts installed on their machines?”

(This one was from a project manger trying to figure out why a web developer used “px” instead on “pt” in CSS). These types of questions from this group are not the targets of this post. That will certainly be the subject of another post.

In this post, I’m focusing on the technical folks who fancy themselves software engineers capable of solving problems. My hope with this post is that people think about the kind of answer they are actually looking for while also considering how their line of questioning is perceived. To help out, I’ve categorized a group of question types that can be categorized as not terribly thoughtful without some qualifiers. Here’s a list of a few:

The “How Do I” Question

No doubt, this is a very popular category of question.  This question can often be valid a number of times especially in absence of adequate documentation. This may be because the API or programming language is new, or you’re working with a homegrown internal framework developed by one guy who has the details all in his head. In these situations, asking: “How do I…?” can be perfectly valid.

However, here are a few cases where it’s not. Take this question for example:

“How do I create a new URL in Java?”

Blink. Blink. A guy with supposedly 6 years Java experience asked me this question 5 years ago and I’m still amazed to this day it was even asked.  You might say that this could be considered a total newbie question and it’s okay. Even so, a newbie should be able to figure out the basics. A little research by Googling “create new URL in Java” would eventually bring you to:

http://java.sun.com/docs/books/tutorial/networking/urls/creatingUrls.html

A two second task and this guy could have snowed us for another day or two. It’s the lack of effort and research know-how that makes the question stupid. You’ve demonstrated that you don’t know what you’re doing and you aren’t capable of solving a trivial problem on your own by performing at least some investigation.

The developer might have been seen in a better light had he made an attempt at searching the docs himself and tried creating a new URL in some type of test case. Had he done that and perhaps asked something like:

“I tried following the docs here, and created a test case to validate my understanding, but I’m not getting the results I had excepted. How do I create a new URL in Java?”

Even though the question is exactly the same, it’s been qualified with some effort. Now I can tell the guy is really trying to figure this out, and more importantly, he wants to solve it but needs a hand. Granted creating a new URL is a weak-ass example, but showing some initiative helps make the question not stupid.

The “Will this Work” Question

It also make my blood boil when I get asked the hypothetical question that goes a little like:

“If I code X and pass it this, will I get Y?”

“Can I create a criteria to query to get this object?”

Here’s a thought: write a damn unit test to validate your question first. Asking, “will this work” without taking a stab at it, demonstrates a severe lack of initiative. What you end up with is a perception of trying to get other people to do your work for you. And that’s what makes this question stupid. Generally, a better what to phrase this is: “I’ve created a test case to pass X through Y, but it failed, and here’s the stack trace.” Now we’ve got something to talk about!

The “Why do I get this error” Question

This question can be absolutely mind boggling sometimes, mainly because you can spend a fraction of a second looking at an error and reading the error message back to a developer just as it was sent to you. My favorite recurring error is with Hibernate apps and some one gets a HibernateException and emails me the stack trace and is “confused” as to why they get the error. Just by scrolling down page to the very end, you can read: “TABLE OR VIEW DOES NOT EXIST.” About 90% of the time, the table name is misspelled in the mappings.

No doubt, sometimes this could be a perfectly valid question and sometimes. But as with all other points in this post, a little research goes a long way. Taking the “TABLE OR VIEW DOES NOT EXIST” error again, while your mapping files may be correct, a DBA may have not provided the developer appropriate grants to the developer. So the question could be rephrased as:

“Why do I get this error? I’ve checked the mapping files and verified the table and column names, but it keeps happening. Any ideas?”

Again, the developers done some digging, but still can’t get to the bottom of it. A developer who’s not thinking about developer grants is not stupid, he may not have considered it and may need a hand at exploring all angles of the problem.

The “What Should I do” Question?

No doubt, you’ve come across the type of problem that seems hopeless and you’re out of ideas. One question that’s generally not a wise one to ask is “What should I do?” A better way to ask such a question would be to have some basic ideas in hand and seek validation. Like:

“hey, I’m stuck on this but I was thinking of trying A and B out to see if that fixes it?”

You’re either going to hear one of three types of responses:

  • “No, that won’t work” or “we don’t have time to do it that way”. Try this approach instead. (If you get a rude response to your idea or get simply shot down without any alternative options, fire up your resume).
  • Yeah, that sound reasonable.
  • Hmm, could work. If doesn’t, maybe try tweaking A with Z and see how that pans out. If that doesn’t work, lets come up with another strategy.

By asking “what should I do” with out any qualifier clearly indicates that you’ve completely given up and you’re not able to take the next step in trying solving your issue. This type of question can be a career-limiting move if asked to your projects team lead or architect. You’ve got to come to the table with at least something moderately intelligent. Otherwise, you’re company definitely paying you more than enough.

No doubt, developers are chronically faced with unrealistic deadlines and given problems that they can’t solve in five minutes. However, if you want to be perceived as a problem-solving engineer type rather that the “I can just bang out code given a spec” programmer type, you need to think about the questions your asking with respect to the answers you want. By providing more context to your question, the quality of of any answer will be greatly improved.

Last night I spent an extended work day trying to track down the source of a Hibernate exception that I have never encountered before. The application in question is a simple data loader application that reads in an XML file populates a Hibernate object graph. The data in the XML file changes from day to day and if element exists in the XML file one day and not the next, the entity is removed from the object graph. All had been working fine until suddenly I started seeing this in my error logs:


Caused by: org.hibernate.HibernateException: Found two representations of same collection: ...

The odd thing was that there can ever be more than one representation of this collection in the application, so I had wonder WTF? I then came across this thread on the Hibernate Forums, but I wasn’t doing anything with Session.clear(). In fact, we weren’t doing manual session management (i.e. flush, etc.).

To make a long story short, the issue was traced down to mapping error. The object hierarchy is as follows:

parent +
       + Component +
                   + component attribute

The removals were being performed on the component by removing a component attribute the Component.componentAttributes collection. The component attribute maintains a bi-directional relationship with its owning component. However, the mapping for the component attributes parent was as follows:

@NaturalId
@ManyToOne(fetch = FetchType.LAZY,
           cascade = { CascadeType.PERSIST,
                       CascadeType.MERGE,
                       CascadeType.REMOVE })
private Component parentComponent;

Note the CascadeType.REMOVE. This meant that when this child was removed, it’s parent would also be removed, hence the duplicate collection. The issue was resolved once the mapping was changed to:

@NaturalId
@ManyToOne(fetch = FetchType.LAZY,
           cascade = { CascadeType.PERSIST,
                       CascadeType.MERGE })
private Component parentComponent;

Of course this could have been caught sooner had some unit tests been a little better, but the cause of this issue sure was a bitch to find. In end it was a subtle mapping issue that ended up getting introduced and wreaking havoc on my day. Hopefully this post can spare someone else some lost hours.

I should know better by now, but the Mrs. has a decent track record of being right. Sometimes. Had I agreed the first time around, we’d have had the right color paint up on the walls this time and we’d be that much closer to getting our loft on the market. As part of my penance and punishment for being wrong, I must inform the internets that my wife was yet again correct the first time and I was SOOOO wrong. You have no idea how wrong. ;) I now must find out how to get this statement up on the Green Monster or at the very least, up on the score board at LeLacheur park. Being wrong sucks :(

There has been some discussion lately regarding integrating JBoss Seam with RESTEasy. Jay Balunas recently made about post on his thoughts on ths subject, so I thought I’d post some of mine. For the record, I am a huge fan of Seam and I think there’s definitely a place for Seam in RESTEasy, so here’s a few of my musing on the subject:

Seam Managed Persistence Contexts

This is a really great feature of Seam and it adds a lot of value to a framework like RESTEasy. If you have a resource that returns a entity that is a complex object graph that will be marshalled to XML, you have a high potential for hitting a LazyInitialzationException. This is especially true if you’re calling a SLSB to get your data because the marshalling process is handled on the web tier, outside of the EJB transaction. If the entity was not fully initialized, your object graph will be incomplete and you will get a LazyInitialzationException. In the initial version of RESTEasy, I used a Seam managed persistence context in order successfully marshall a complex entity using JAXB without getting a LazyInitializationException. I could have written a filter that was similar to the Spring OpenSessionInViewFilter to span the transaction over the entire HTTP request, but Seam made this problem transparently go away in very elegant manner.

Transactions/Conversations

Conversations are one feature of Seam that cause a lot of folks to raise concerns about the stateful nature of the framework in regards to REST. However, I think in some instances, some of the conversational aspects of Seam can be utilized in a RESTful design. Take this thread on the JSR-311 mailing list from Bill regarding Transactions in JAX-RS:

No, I don’t want JAX-RS to have a transaction model :)

One pattern I’ve seen in REST is how they solve distributed
transactions.  The pattern seems to be

/transactions/{tx-id}/.../whatever/your/real/resources/are

So really the transaction resource is allowed to contain any resource
the server supports.  (I hope you are following me, if not I’ll expand).

IMHO, this is something I think Seam could lend a hand with. Taking both Seam’s support for conversations and jBPM, you could conceivably use a long-running conversation to implement such a feature whereby you might end up with something like:

/transactions/{conversation-id}/.../whatever/your/real/resources/are

It’s not a fully baked idea, nor might it be quite the same thing that Bill is talking about. However, it could potentially be RESTful if implemented properly and Seam already provides the plumbing for this out of the box.

Entity Resources

The Seam framework (as in org.jboss.seam.framework), offers a lot of convenience features that make working with JPA and Hibernate a breeze. I had a silly idea a while a back about how to expose entity beans as a resource without the need for a dedicated resource class. The idea wasn’t fully baked (and in hind sight, those details are actually kinda crappy and overly verbose), but the general idea was to make it easy to navigate elements of an object graph. For example, if you were to access the following URI:

http://myhost/contacts/12345

You’d end up with the full object graph as XML for contact ID 12345. If you just wanted to look at one address for that contact, you should be able to call:

http://myhost/contacts/12345/addresses/home

And you would get just the XML element for the contact’s “home” address. What I don’t want to do is create a separate resource class for each element and each collection type in the object graph. You shouldn’t have to create a ContactsResource, ContactResource, AddressesResource, AddressResource, etc. Ideally, you should be able to have one class, or just the entity itself, that can represent the resource. I’m currently working to refine this idea for RESTEasy and much of the Seam framework API could be useful in making this a reality.

I could go on, but I think there’s a lot of value that Seam can bring to RESTEasy.