Pencils Down

This weblog is about my experiences in software development

Browsing Posts in Uncategorized

We ran across cases where a list (had correct size()) contained null objects on some of our queries.  At first we just put in a work around to ignore nulls.

However, a new use case arrived that required an auxiliary table to be populated.

Looking into the issue, the new table had a composite key with several elements.  It turns out when Hibernate is attempting to populate the object it verifies that each of the composite key elements is not null.  If it finds one that is null then it returns a null object.  The thinking is that a PK should never have a null.

Well, that’s nice rhetoric when you have a new system where you design from the ground up, including the database.  My current environment is the opposite: massive database compiled with over 20 years of data and associated changes.

The solution is to remove any element from a composite key that may be null.  In the particular case we were dealing with that was possible.  I can imagine there are other cases where that may not be possible.  It would then be pretty painful to massage the data to the form you need (not nulls) effect the change across the various applications using the data.

Expected it to work out of the box, like the regular version does.

Seems to be a hack  – not ready for real work yet:

- simplest forms corrupt the jQuery js (on desktop IE)

- simple page footer buttons don’t like to the href specified, so get errors just trying to move between pages

Have you had better luck with this?  Recommend a better toolkit?

Last week Microsoft buys Skype for $9 billion.  This week LinkedIn has IPO initially prices at 275 times sales.  Opens up 80%+ so I think we are near 500 times sales.  I need to say that again:LinkedIn IPO on Wall Street 500 times sales.  The best part is they are class B shares – no voting rights.  Yes, my blood is now solid green with envy.

What kind of numbers are being dreamed up now for the upcoming, BIGGER groupie companies like FaceBook?

While it’s good to see money come back into the technical sector it scary that we are heading into another bubble quickly that will burn through all the capital available in the market.  The post dot-bomb era was extremely painful.  How can this be avoided?

We are making a phone version of a web site we have developed.  Looking around it is pretty amazing what people are getting away with. 

One of the primary vendors for reworking your current web site to a phone-enabled/mobile version will convert your site and charge you a monthly fee to maintain/host the mobile site starting at $250 per month!

So, how much work is involved in doing this?  I imagine a set of scripts flips through your site and strips out all the ‘bad’ mobile things – big pictures, css, javascript and produces a site where humans go in and tweak to make things look and behave in a mobile-friendly manner.  But, once it is done, where is the forever fee per month coming from?  Sounds like something ripe for Far Eastern outsourcing groups to come in and destroy pricing.

Another company produces an phone emulator package that you can use for later testing.  While interesting and cool again we have outrageous pricing starting in minimum of 6 minute increments for using their emulator!  If it weren’t so sad it would be comical.  I know emulators have been around for quite a while.  What is stopping some freeware place from doing the same thing on a shareware basis?

I am usually a Capitalist Republican but I have no empathy for these rip offs.

Let’s see (Microsoft close to buying Skype):

- eBay buys Skype for 3.1 billion (all assumed it was a collosal mismatch)

- eBay sells 2/3’s of Skype for 1.9 billion (told you it was a bad idea)

- MS buys Skype for 8.5 billion

- That leaves (3.1 – 1.9 + 2.8 (8.5/3)) 1.6 billion net to eBay

It sounds like Meg is a lot better at this than many people (including me) thought.

Of course, the whole question of whether MS can do something useful with Skype or should have paid anywhere near this amount is iffy.

Maybe this means all of these companies with large cash hoards are finally getting out there.  Unfortunately it sounds like everyone is deciding at the same time, hence the price tag for Skype.  Assume there is competition for the company.

We are using the dirty form jQuery plugin, dirtyforms.  It works well, except there are a few times when we would like to know if there is anything dirty on the page.  The documentation says to use a function, however that function is not available or working or …

I have been using:

var anyDirty = false;
$('form').each(function() {
if ($(this).are_dirty())
anyDirty = true;
});

There are several posts online that show parts of dealing with the browser unload event.  Most of them are incomplete.  The trick is that if you return anything from the event handler then the browser leaving page dialog box will come up.  If you don’t want the dialog box to come up then return nothing.  For example,


//try... to detect browser/tab close
//if user clicks a link or submits a form we don't care here
var inFormOrLink = false;
$('a').each(function() {
 $(this).click(function(e) {
  inFormOrLink = true;
 })
});
$('form').each(function() {
 $(this).submit(function() {
  inFormOrLink = true;
 })
});
//return any value means prompt user to make sure they want to leave the page
$(window).bind("beforeunload", function() {
 //regular links are ok (regular dirty check will kick in)
 if (inFormOrLink) return;
 //if we get here user has done something to change url - Back, History, Close Browser
 //if something dirty on the page, make sure they want to leave
 var anyDirty = false;
 $('form').each(function() {
  if ($(this).are_dirty())
   anyDirty = true;
 });
 if (anyDirty) return "My App"; //IE puts the string in the dialog box, FF puts up their own message
 //otherwise bye, bye
 return;
});

The first two functions are trying to determine if the user just clicked on an anchor or hit submit on a form.  Both of these generate a unload page event, but that is ok since the user likely means to do this.

Then in the unload event handler we check if the user did click on something ‘legal’ in a form.  If so we are done.

Next we would like to check if the user has dirtied some data in a form on the page.  We are using a jQuery plugin for dirty checking so we poke around the forms and see if anything is dirtied.  If there is something of interest we want the leaving page dialog box to come up so we return the string we would like to see show up in the dialog.  As noted the browser really does whatever they want for the dialog box text that comes up.

If nothing is dirty we just return – do not return any value otherwise you get the dialog to show up.

If you are using the PaginatedList interface to pass the result list to the JSP page that has display:table tag and the result list is empty the display tag library can generated a divide by zero exception in the JSP while attempting to render the table.

My workaround is to not use the PaginatedList interface if the result list is empty.

I like Spring MVC.  It is a great next step in the Spring history of Java/Web development.

I don’t like that Spring has decided that if you redirect from a POST then it unwraps all request parameters and throws them onto all subsequent URLs that are generated.

We have what I think is a fairly common search/results page.  We POST the search criteria when the user changes some aspect and GET to perform manipulations within a search result (such as page, paging, or sorting).

I had been storing the criteria in the model passed to the POST request.  This appears to be the culprit.

If I remove the model setting of the criteria and just store the criteria in the true HTTP session and redirect to my GET handler then everything works correctly.  No ugly URLs with umpteen parameters off the side of the screen.

So, the order of steps is something like:

  1. User changes criteria and POSTS to handler
  2. POST handler stores criteria POJO in the HTTP request object and redirects to same page GET handler
  3. GET handler retrieves criteria from HTTP session and performs updated query

This error is the result of trying to mock a class instead of an interface.  In order to mock a class you have to use the class extensions instead.

So, change your code from:

import static org.easymock.EasyMock.*;

To:

import static org.easymock.classextension.EasyMock.*;

I think it’s just historically how EasyMock got developed:

  1. first interfaces like nice Java/Spring/JUnit theory says your supposed to develop,
  2. then normal classes for the working Java programmers of the world.