Pencils Down

This weblog is about my experiences in software development

Our normal query execution path is:

1) change query to perform a select count on the query to get paging information established

2) load a page from the query

This works fine when you have something like “select distinct table.id” – just replace the from part of the query to be “select count(distinct table.id)”

Once in a while we have the case of wanting a  multiple column distinct, e.g. “select distinct table1.id, table2.other,…”  HQL doesn’t let you use multiple columns/objects in a select count distinct.

The first step is to reduce your query from objects as to atomic values.  Instead of getting the Address object, just get the Address id.  This will be some Integer or other native Java that does not require any materialization (and follow-on Hibernate querying to fulfill due to aggressive loading).

So, now your standard query looks like “select distinct c1, c2, c3, …” where everything being selected is a native Java type.

Here is the leap of faith: just load the entire result set into a List and get the size() of the list.  Something like: 

Integer size = query.list().size();

Assuming you are performing some limits on the query, say under 20K records I think we are looking at about 50K of space allocated for the List resultset.  Further, the execution and transfer of data from the database to Java should be very quick (if not you probably have some work to do to optimize your query in the first place)

My underline and bold in description below.  I thought these kind of posts evaporated.

Makes you wonder what the rest of the employees are bringing to the table if this person knows everything and does everything.

————————

VP of Web Application Architecture for a fulltime position with our client in downtown <city>.  (he or she must be hands on)

Objective:
Provide technical architecture and design leadership for large scale digital marketing campaigns and technology solutions

Skills:
10-12 years of Application Development experience

2-4 years of Complex Application Architecture and Design

· Expert J2EE developer and architect; formal certification is preferred

· Significant experience architecting and developing web applications

· Demonstrates expert knowledge of relevant technologies and architectures including J2EE Application Servers and Content Management including experience with one or more industry leading products (e.g. Vignette, Interwoven, Fatwire, Alfresco, OpenCMS)

· Expert knowledge of Object Oriented programming and associated methodologies such as data/object modeling and pattern based design

· Expert knowledge of XML and the associated technologies (e.g. XSLT, FOP)

· Expert knowledge of Unix (Linux, Solaris) and good working knowledge of Windows

· Experience in legacy systems integration

· Able to define hardware requirements

· Expert knowledge of software engineering methodologies

· Working knowledge of security concerns for web applications.

Responsibilities

· Stays current with emerging technologies and contribute to overall technical direction of Technology

· Responsible for setting Coding standards

· Perform code reviews

· Clarity and consistency of code; code well documented with minimal bugs and errors

Client:

· Excellent client facing skills

· Strong presentation and documentation skills

· Nurtures relationships with technical clients

People:

Helps mentor Web Developers, Software Engineers, Senior Software Engineers and Principal Software Engineers in technical skills

Strong written and verbal communication skills

Works with others to provide technical direction and efficiency

Leads technology shared learning sessions

Business:

Lead and architect technical direction of one or multiple projects

Identify and champion client technology synergies and optimization

Propose and support incorporation of new technology

Test new ideas / product for applicability to project goals

Document functionality and designs at an architectural level

Knowledge in vendor negotiations, vendor evaluations, specifically geared towards technical evaluation of software and organization

Participates in new business pitches when required

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.