Software PDP

Software Development Professional Development Plan

Category: java

Software Development with an SSD

I am writing this on a mid 2012 MacBook Pro with:

  • 13.3″ display
  • 256 SSD (R/W is over 400/400 MB per sec)
  • 2.9 GHz Intel i7 dual core processor
  • 8 GB RAM

MBP 13.3 2012 256 GB SSD 2.9 GHz i7 8GB RAM

Why is this worth mentioning?  The SSD alone is worth its weight in gold.  Boot up time is about 12 seconds.  Not a bit deal you say?  Try unplugging, sleeping your computer, and going to a meeting.  Try whipping out your computer before a demo to make a change, verify something, anything.  This makes a huge difference.

Aside from boot up time, applications load nearly instantly, installations don’t make you wait, and the best for me: compile times are next to nothing (specifically Java build times with Maven).  The speed of reading and writing to disk is vitally important, and so much better with an SSD than even installing tons of RAM.

If you are a developer and considering a new computer purchase, consider the SSD your only option.  This is easily the fastest development computer that I have ever used–even when compared to two quad processors, 8+ GB RAM workstations.  You won’t regret getting the SSD, but you will regret not getting it if you ever experience using one for development.

Additionally, if you purchased an Apple computer with a free upgrade promise, then you will have to submit a request on their website: http://www.apple.com/osx/uptodate/

Oracle, IBM, and Apple on OpenJDK

As a Java software developer, I am excited about the recent press releases from Oracle, IBM, and Apple to partner on the future development of OpenJDK.

I developed Java software solely on a Mac for about five years, and while I love the Mac, didn’t really love Java on the Mac.  I ran into issues with the Java SE6 JVM that seemed to be more of a headache, than the Mac experience that you expect from their auto-update utility.  Hence, why I believe that this is a step in the right direction for Apple and Oracle.

IBM, on the other hand, has really caught my attention recently.  Their developerWorks articles and resources have been a huge help to me recently when checking out JNI best practices, and just an introduction to JNI.

What I would really like to see from an OpenJDK alliance is a free, open source, real-time JVM.

As I get into more embedded and real-time Java programming, I am finding that the real-time Java community is very a specialized subset of Java developers, with an interest in the academia of real-time computing and Java in general.  With that said, it appears that this group of developers using real-time Java have their expenses paid either by the companies contracting their work, or by association with an academic institution.  And by expenses, I mean the $7000-$14000 up-front development tools prices for Sun Java Real-Time System, IBM WebSphere Real-Time, Aonix PERC, and Aicas JamaicaVM.

Oracle, IBM, Apple, OpenJDK partners: make us a free, open source, real-time JVM and JDK that will inspire innovation.

Now that OpenJDK has two BIG players on their team, why not make something BIG happen, other than just the expected?  The truth is, Apple is an embedded device company, IBM works on all fronts of Java technology, and Oracle/Sun could stand to earn Java a more reputable name for embedded and real-time programming.  In spite of how great Android/Apache Harmony/Dalvik is, Java ME, etc., Java is still thought of as a heavy, non-deterministic, non-real-time capable language by many real-time and embedded developers strictly using C/C++.  I know that the real-time JVMs are out there, but they are expensive, and unrealistic for innovation without a ton of money up-front.  I believe the opportunity to be available with the OpenJDK project at this time with its recent alliances, and I hope to see innovation in the real-time Java arena.

Using Squiggle for Object Oriented SQL Selects

I am now testing the use of Squiggle for writing SQL sellect statements in an object oriented fashion.

Coming from a background exclusively using Hibernate for database interaction, I am looking for a similar style of query building.  I would also like to bring some level of safety to the table names and column names, so that I am not typing in the names of tables and columns when writing queries.  It seems that Squiggle provides the simple functionality that I am looking for, paired with Spring configured table map beans with the table name and column names.

A simple example provided by the Squiggle authors on their Google Code project page is:

SelectQuery select = new SelectQuery();

Table people = new Table("people");

select.addColumn(people, "firstname");
select.addColumn(people, "lastname");

select.addOrder(people, "age", Order.DESCENDING);

System.out.println(select);
Which produces:

SELECT
   people.firstname ,
   people.lastname
FROM
    people
ORDER BY
    people.age DESC

Not great, but not bad for cleaning up messy string-concatenated queries.

Spring JSON Response for ExtJS AJAX Request

Both ExtJS and Spring have proven to speed up development for many projects on which I’ve worked. Both frameworks handle JSON very well, and so AJAX development moves very quickly. I will show you the quickest AJAX example that I can using Spring 3.x and ExtJS 3.x.

In your controller:

@RequestMapping(value="/exampleJSON", method=RequestMethod.POST)
@ResponseBody public Map getExampleJSON() {
    Map jsonMap = new HashMap();
    jsonMap.put("success", true);
    jsonMap.put("total", 1);
    jsonMap.put("items", new String[]{"item1"});
    return jsonMap;
}

Things to note:

  • Your items can be any collection of objects that you wish. The JSON response will be the String representation of each field within those item objects.
  • The request method must be POST. ExtJS requests via POST when performing an AJAX request.
  • The three items that must be included for ExtJS are:

{"success": boolean,
 "total": number,
 "items": [array]}; // This can be any name.

As long as your Spring JSON configuration is correct, the response will be a purely JSON response with exactly what your ExtJS needs.

For a more type-safe approach, you can create a class to return as your response body JSON object.  I usually call these classes command classes.  When I to go this route, I have a base ExtJS JSON command class that has:


boolean success = false;
int total = 0;

I then add the collection of items in the extending command class, so that it can be a List, Array, Set, or whatever else suits the requirements.

Having a command class does offer you the advantage of binding JSON coming from the request directly to the command class via the @RequestBody Spring annotation. The fastest way to have JSON returned as the response, though, remains the Map implementation in my experience.

64bit unsigned ints and XML-RPC

XML-RPC is a great way to communicate data between different platforms, such as C++ desktop, Python web, and Java mobile.  However, the XML-RPC spec is very limiting when it comes to data types.  In particular, a C++ application may have a 64bit (i8) integer that it needs to send over XML-RPC, however would not be able to, since XML-RPC is limited to 32bit (i4) integers.

There are a few solutions to this problem, but all involve extra processing time to convert them to a different data type on both the sending end, and then again on the receiving end.  Not only does it take longer to process the data, but also begins to clutter the code with conversion code, which can be confusing.

Two methods of transmitting  this data would be to convert the long integer to a string or convert it to a byte array.

Should the XML-RPC spec be updated to include longer integer values?  I think it should.

Customizing Webapps with Maven WAR Overlays

Many companies have a core product, or many, that are sold with the intention of customizing that product to the client’s needs. There are a few approaches to this, and one is built directly into Maven’s WAR plugin.

Maven’s WAR plugin will take any dependencies that have a type of “WAR” and overlay them on top of the building projects WAR, before adding the building project’s files. This alloys quick project creation, customization, and retains the core features that are built into the overlaying WAR dependency.


<dependencies>
<dependency>
<groupId>com.softwarepdp</groupId>
<artifactId>overlay</artifactId>
<version>1.0.0-RELEASE</version>
<type>war</type>
</dependency>
</dependencies>

Spring in Practice with Spring 3

Spring in Practice by Wheeler(s); Manning Early Access ProgramManning is publishing a new (as of this post) book entitled Spring in Action, by Willie Wheeler and John Wheeler, on which I will be basing my software development PDP for January to June 2010. The book is mostly written, but is part of the MEAP, which means that the final version has not yet been published. I have been reading through many chapters, and already recommend Spring in Practice.

I will mainly be focusing on Part 2 and Part 3, which covers basic Web application functionality and domain-specific topics, respectively. The reason I am focusing on these parts is because we often get many of these features for free when starting a new project, whether via a ramp-up project like AppFuse, or via internal company base projects.

My experience with Spring began in 2006 with Spring 2.0. I have developed projects using 2.0, 2.5, and am now approaching 3.0. I am excited about Spring 3.0, and will be focusing on the new features that it brings while developing my PDP project.

Update: The book has yet to be released–almost a year later. IMO this is bad sales practice; something I’ve seen at a previous job and should have avoided. Moving on…

Follow

Get every new post delivered to your Inbox.