The Windows SDK

Posted September 7, 2007 by alexharvey
Categories: Java

I was reflecting recently on what it was like during my first few weeks as a professional software developer just out of college. My first job out of college was for a small consulting firm that specialized in writing custom Microsoft Windows programs in C. This was 16 bit Windows 3.1. One way that I went about getting acquainted with Windows programming was to take home the SDK programmers reference and read the API from a to z. This actually proved to be beneficial as horrible as it may actually sound. I believe I got through the API’s in about one weekend of casual reading. Who can forget CreateWindowEx()?

HWND CreateWindowEx(
DWORD dwExStyle,
LPCTSTR lpClassName,
LPCTSTR lpWindowName,
DWORD dwStyle,
int x,
int y,
int nWidth,
int nHeight,
HWND hWndParent,
HMENU hMenu,
HINSTANCE hInstance,
LPVOID lpParam
);

Shortly after this a lot of Windows programmers, myself included, went through a transition period as a C++ compiler and MFC was made available from Microsoft. What a wonderful idea it was and once again the power of abstraction in computer science came to the rescue to hide the gory details. At the time, MFC was a wonderful thing.

Bringing this to today’s environment, one could not reasonably read through all of the JDK in a weekend I don’t believe. It would be a task more painful than reading through the Windows SDK for me. The breadth of the entire programming environment for Java is formidable if you attempt to survey the entire landscape. We have abstractions built upon abstractions. Entire frameworks get raised up to correct shortcomings in the JDK, or in the best cases provide abstractions that may have had little value when the JDK was first designed.

I think much of our progression has come from the power of the Internet as a collaboration tool. When I took up Windows programming the only sharing of ideas and issues came from around the office. The notion of using the Internet as a learning or collaboration medium for professional developers, at least for me, didn’t really exist at the corporate level. Collaboration is a wonderful thing.

As an exercise, it would be quite funny to re-create the typical 16 bit Windows development environment and attempt to write some small application that by today’s standards might be quite trivial. I would venture to guess that using the 16 bit Windows SDK to send and receive an XML request over HTTP would be a challenge. Recreating the environment alone would take time. Anyone still have a copy of Brief for DOS?

Google Notebook + Gears

Posted August 25, 2007 by alexharvey
Categories: Google, Mac

Since moving mostly to a Mac for software development, one piece of software on Windows that I have been unable to find a replacement for is Microsoft OneNote. I use OneNote as a repository for notes and coding snippets that I find useful, want to try out, or just simply want to remember for some rainy day. Its beauty is in its simplicity as a quick note taking tool. I can paste something in it when I am in a hurry and then return and file it later when I have time. Certainly there are similar tools on the Mac but I simply haven’t broken my links with OneNote yet.

I had not paid much attention to Google Notebook until a few days ago. The Firefox browser plugin is brilliant. Now all the tool needs to be a complete replacement is offline support through Gears. I’m sure this will be soon. When the offline support is added, it becomes more than a replacement for OneNote for me. It becomes a useful note repository that isn’t tied to a single machine.  After the offline support a desktop client and a mobile client would certainly follow.

fun with FileReader

Posted August 24, 2007 by alexharvey
Categories: Java

This morning I was innocently writing a simple program to read from a file using FileReader. I had setup the typical loop to read until the end of file was reached.

Reader r = new FileReader("myfile");
int i = -1;
while ((i = r.read()) != -1) {...}

So then I went about testing my program and discovered my loop was infinite. It turns out that read() won’t return a -1 if some other process has the file opened, or at least in this case I had the file open in Oracle SQLDeveloper. This is probably old hat to many but ouch. I suppose the better way to write such a simple test to inspect whether or not the file is already open? The puzzling part though is why the file pointer gets reset when the read reaches the end of the file. BufferedReader behaves the same.

a simple medical records application

Posted July 27, 2007 by alexharvey
Categories: Healthcare, Java

I have dusted off an application I wrote while part of a startup company about 5-6 years ago. The application is medical records application that provides a GUI for management and storage of a patient’s information. It also provides for synchronizing this information with a smart card. The GUI is written in Java Swing and the backend logic is also Java. Since the application was conceived of in 2001 it uses EJB. Fortunately I did design the architecture of the GUI so that it deals through a plain Java model and doesn’t have any direct knowledge of the backend implementation.

So in my nearly non-existent freetime I am in the process of overhauling the application to modernize it.

My first step was to Mavenize. This was not particularly difficult since the Swing application is essentially just a plain Java application with a main method. I plan however to completely gut the backend and build service oriented classes to replace the session beans from yesteryear. This task however is a bit down the road and perhaps there will be future blog entries reflecting on my options here. Anyhow the simple project archetype was all I needed here for my jumping off point.

I’ve also decided to gut the plumbing for the smart card interaction. Back in 2001 we used OpenCard as our facility to abstract communication with the smart card. I have no idea what the technology choices are today but I did visit http://www.opencard.org and the website appears untouched. So for now the application will simply be a fancy database reader and not interact with data from the smart card.

Here is a list of todo’s to modernize:

  • introduce Spring for configuration and ioc.
  • include log4j
  •  figure out a backend strategy and architecture to replace EJB
  • determine an app server to develop with Tomcat or Glassfish

In the end I’m not sure what to do with the application. If I can get the smart card link successfully re-established it could provide some kind of value but as just a database viewer it is basically a fancy sample application. We’ll see.

dabbling in the dark arts

Posted June 21, 2007 by alexharvey
Categories: Java, Oracle

Ever tried to get deep into performance tuning with Hibernate? It is not a well traveled path I am finding. In general, I think Hibernate has excellent documentation but recently I’ve been doing some work in performance tuning a highly transactional application and I’ve been struggling to find useful resources. Here are some areas I’ve found difficult to find documentation.

  • turn on logging for the Oracle thin JDBC driver. Much of Oracle’s documentation is outdated and it refers to deprecated methods on the driver.
  • ehcache is a bit difficult to obtain statistics from if you ask me. I haven’t been successful in getting ehcache installed into JConsole yet although the documentation makes it appear simple enough.
  • Hibernate also generates statistics and this is helpful but getting cache statistics on the second level cache can prove problematic

Anyhow, I’ll have future blog entries when the above issues I am having are resolved. Where are Professors Lupin or Snape when I need them?

my Mac and PC laptops

Posted June 12, 2007 by alexharvey
Categories: Java

I have two laptops. I have an HP nc8230 and a MacBook Pro core duo. Both machines have 2 GB of RAM and perform pretty much the same. The obvious difference, of course, is that one runs Mac and one runs Windows. No surprise. The PC laptop has one small glitch that really bugs me and stands as a testament to why I’d prefer to use the Mac, given the choice: the volume controls.

For some reason the volume buttons on the PC laptop just stop working over time in a Windows session. Who knows why but after a period of time they no longer function. This seems par for the course in Windows. Things stop working now and then.

This isn’t to be expected on a Mac. I can’t think of the last time I was truly let down by hardware not working on my Mac due to some sort of software problem.

thoughts on Flash Remoting

Posted June 7, 2007 by alexharvey
Categories: Java

I have been doing some work building a backend to support a Flash client. The backend provides a set of services for the UI front end like registration, login validation, and generally just persisting state to the database.

Early on we made an attempt to write the communication between the front end and the backend with a web service using Apache Axis. We were halted with many strange errors and then came across this (obscure IMO) technote from Adobe. After this discovering we switched to using Flash Remoting for communcation to the server.

Here are some things that were learned.

  • Remoting puts some burden on the Flash developer to syntactically mimic the complete Java class structure that is being returned. This can be tedious although there are some open source tools for writing out ActionScript based on consuming Java classes.
  • Passing back Hibernate-style POJOs that contain back references can be problematic. The Adobe Remoting servlet can run into stack overflow as it tries to serialize/deserialze circular references.
  • Remoting is fast, faster than web services. I have no data to support this but Adobe may have some someplace.
  • Remoting is easy to debug at least on the Java side. The servlet provides incredibly verbose logging so it is straightforward to look at what is being passed to/from the client.

In general, one big design decision should involve decoupling objects passed back to the client versus objects used to represent database persistence. Maybe this is obvious but I can tell  you it is easy to get sucked into returning objects that are paired with the data model.

Upgrading to Ubuntu 7.04 (Feisty Fawn)

Posted April 26, 2007 by alexharvey
Categories: Linux/UNIX, ubuntu

So I connected to my Ubuntu box from my Mac using XDMCP like usual and decided to attempt the upgrade using Software Updates. The install took probably 3-4 hours while I did other work. Well everything went fine until I tried using the keyboard. The upgrade managed to remap my keybaord to something completely unusable at least in GNOME. This may be difficult to work out since I cannot even type in my password when prompted for permission to change system settings.

Photokit Sharpener

Posted April 17, 2007 by alexharvey
Categories: Digital Photography, Lightroom, Photoshop

I have been using Adobe Lightroom for less than a month now. I think of Lightroom as a hugely improved interface on top of Adobe Camera Raw and currently LR’s biggest drawback for me is its inability to merge databases. I’m sure this will change.

Meanwhile, I’ve picked up Photokit Sharpener. I wish I had been using this tool all along instead of struggling with Smart Sharpen. The tutorial for Photokit Sharpener is excellent and my results after processing maybe about 30 or so photos has been very satisfying. I could never have gotten close to these results with my basic at best knowledge of how to wield Smart Sharpen in Photoshop.

.Mac needs a facelift

Posted January 25, 2007 by alexharvey
Categories: Mac, photography

I really like .Mac

I’ve tried several photo gallery sites and I like the flexibility of .Mac and the fact that it integrates into iLife. That much is great but the service is severly behind competitors like Flickr and PBase.

One thing that is needed is a more robust photo gallery. Sure I can export my photos from iPhoto. This is a great start but where are all the features after that? There’s no EXIF display. Why not? There’s no tagging mechanism, no comments, no contacts list, etc. There needs to be more for the price of the service.

One more thing: I think the calendar mechanism is very hidden and obscure. Why is this? Why isn’t calendar a top level menu item once I login?

.Mac team please tell me you are modernizing the service or better yet coming up with something more innovative.