Sunday, January 31, 2010

GWT and Modules

We've been using GWT for our Web application development at my company for about a year now.  Although GWT doesn't eliminate ALL of the struggles with HTML User Interfaces, it sure does help.  One of the things we are realizing in our development is modularity.  No matter what framework I've worked with over the years, that valuable reuse has evaded me.  Templates helped.  Frameworks helped.  But in the end, most of the UIs were specific to the applications.

With GWT, our team has started to realize some of the benefits of OO programming.  We have created some reusable components that are common to all of our applications.  Here are 3 GWT modules we have produced that aid in our new project setup:


  1. Login module - This is a module that creates a login dialog, interfaces to our AD implementation on the server, and will maintain the user in session for the applications.  It also contains a 'secure servlet' framework that will allow developers to easily specify the roles that can access services.
  2. Application Info module - This one may seem pretty trivial, but this is a big help with deployments and support.  This module displays some build information in the footer of our applications: Application name, application version, code repository version, build number, and build time stamp.  
  3. Logger - This module integrates to a logging/notification framework that will allow developers to get notices about critical failures, and to see all logging for all applications in a single interface.
The ability to drop in a few .jar files, configure a couple of servlets, and be given this rich set of functionality has improved the quality and speed of our application development.

Thanks again Google.

Friday, January 22, 2010

Setting Expectations

I am finishing my masters degree in software engineering at Carroll University.  My last two classes are this spring and one of them is, "Software Project Management".  We had the initial class last night, and the instructor asked the students to write down 10 words that describe software project management.  We then went around the room and read off our lists.  Guess what?  Most of the students had relatively negative words, including: "Too Many Meetings" and Stress.

Another common theme was Expectations.  When I was asked why I thought the comments were so largely negative, I had to respond that I felt it is difficult to meet user expectations in the workplace today.  Since I work for a small company and we are always on tight deadlines, we often leave out the 'fit and finish' that users are used to in commercial software like Excel or Word.  Given our staff and the expected time to deliver the functionality we are writing, we simply cannot add those niceties, and they are often expected.

What niceties are we talking about?  Here's an example.  On an application at my workplace where field staff can enter data into forms, they expect to have all the features that Word would have like document recovery, rollback, etc.  Those are all important, but they were not in the application spec (It does have a wonderful 'auto save' feature, but if your laptop loses battery and dies, you lose everything after the auto save). Another example is a group that felt that 'clicking a button' for workflow was too inefficient and that the web app they were using needed hot keys, how hard could that be?  Of course, adding these features is possible, but management typically decides that they are not valuable enough to add, and we move on to other tasks.

My professor pointed out that users have ALWAYS had higher expectations of technology than what developers can typically deliver (and he's been doing this for a long time - think punch cards).  So the question is:

Is the trick to successful software projects setting low user expectations?  


If the users don't EXPECT hot keys or document recovery they won't be disappointed when they are not there.  Of course how do you anticipate all of the expectations that you don't know?  Communication and common sense will help, but those will only take us so far.  User Interface testing and reviews will also help, but even those don't really unveil every expectation and I have found it difficult to get time for those tasks approved.  So, I ask, How do we set proper expectations on software development projects?

Sunday, January 10, 2010

Paypal PDT

I thought I would follow up my previous post with one that points out some good practices, and potential pitfalls when using really simple interfaces.  The DS Volatility Trends Web site is going to use the Paypal PDT option, where a user will be redirected back to the DS Volatility Trends Web site after payment is complete. The API is VERY simple.  You tell Paypal which page to redirect to, and it redirects to that page with a single get paramer: tx.  You then use this parameter, and your user key to get more information about the tx and to verify it for security purposes.  Here is the output of the response for a first test, run against the sandbox, with user keys omitted:


SUCCESS
mc_gross=5.00
protection_eligibility=Eligible
address_status=confirmed
payer_id=
address_street=1+Main+St
payment_date=09%3A30%3A43+Jan+09%2C+2010+PST
payment_status=Completed
charset=windows-1252
address_zip=95131
first_name=Test
mc_fee=0.45
address_country_code=US
address_name=Test+User
subscr_id=
payer_status=verified
business=
address_country=United+States
address_city=San+Jose
payer_email=
txn_id=8NJ4974863519050H
payment_type=instant
last_name=User
address_state=CA
receiver_email=
payment_fee=0.45
receiver_id=
txn_type=subscr_payment
item_name=DS+Volatility+Trends+Newsletter
mc_currency=USD
residence_country=US
transaction_subject=
payment_gross=5.00



Here is a sample after I inserted a custom value:

SUCCESS
mc_gross=5.00
protection_eligibility=Ineligible
address_status=confirmed
payer_id=
address_street=1+Main+St
payment_date=09%3A06%3A15+Jan+10%2C+2010+PST
payment_status=Pending
charset=windows-1252
address_zip=95131
first_name=Test
address_country_code=US
address_name=Test+User
subscr_id=
custom=12631431526791
payer_status=verified
business=
address_country=United+States
address_city=San+Jose
payer_email=
txn_id=0LG419336A6914908
payment_type=echeck
last_name=User
address_state=CA
receiver_email=
receiver_id=
pending_reason=echeck
txn_type=subscr_payment
item_name=DS+Volatility+Trends+Newsletter
mc_currency=USD
residence_country=US
transaction_subject=
payment_gross=5.00



Can you see the potential issue?  Inexperienced developers often take the first result set and start parsing it, line by line.  Some pseudo-code to represent this:

//Code has other problems besides the one being highlighted...

//Get String from stream...
String[] values = returnString.split("\n");
//now get the values of each line, assuming they are in the correct order
mcGross = values[0].split("=")[1];
protectionEligibility = values[1].split("=")[1];
//continue with all other values..


The code above would break as soon as the new variable is added, since the variable is returned in the middle of the list, all variables after 'custom' will be offset by 1 in the index.  In addition, I don't see any specific guarantee that the order will always be the same (Although that would be a good practice for Paypal to implement...).  At any rate, it is better to handle the values in an order-neutral way.  In Java, I would do this by parsing the string and creating name-value pairs in a Map.  This requires a little more code up front, but will save lots of potential errors down the road.


//Better but still needs work to be robust....


Map values = new HashMap
String[] values = returnString.split("\n");
for(int i=0; i < values.length; i++ ) {
    String[] thisValue = values[i].split("=");
    values.add(thisValue[0], thisValue[1]);
}
//Now values has ALL the values if new ones are added or the order changes,
//we don't care.  We're also sure we set the value with the right key
mcGross = values.get("mc_gross");


As you can see, with the second implementation, the code will still work just fine with the new 'custom' variable returned in the results.  The order of the variables is no longer important, and frankly, I think it is more expressive - mc_gross key is clearly being tied to the mcGross variable.

Paypal Integration

Paypal API

I've had to set aside my Android project temporarily to help out a friend.  He has been working for years on refining an algorithm that uses the VIX to increase the ability to predict the volatility in the market.  He has gotten it to a point where it is accurate and reliable, and is starting a service for institutional investors.  Since he's just starting, but he's serving business clients, he wants to be able to take payments over the Web.  The site will be up soon - DS Volatility Trends.

So, instead of working on learning Android, I've been learning the Paypal interfaces.

How has this gone?  A little frustrating, to be sure, but when I think about it, Paypal is a company that really knows their market.  When I first started looking at the interfaces, I was irritated.  The documentation was plentiful to be sure but a lot of it was at a high level, or very watered down.  In addition, I had to continually re-interpret the documents because the terminology mixed metaphors.   For instance,  all interfaces they offer are referred to as APIs.  As a professional developer, when I hear the term API, I immediately think of method calls and returns.  When I hear the term Service or Web service, I immediately think remote connections and these days SOAP or RESTful requests and responses.  While Paypal offers all of these things, they seem to all be called, API.  While technically true, it was a bit of a shift to adjust my thinking.  Perhaps I'm getting too old.

After reading the documentation, and working to set up DS Volatility Trends to interface to Paypal, I believe that Paypal has set up its site to target its core customers - very small businesses, home shops and others who can't afford large development staffs and investment in infrastructure to support the necessary security needed to take payments and process credit cards directly.  They are often integrating Paypal themselves.  My experience with small businesses that have spoken to me about consulting is that even when they do outsourse, they will often go with the 'cheapest route' as well, which, often means young, inexperienced developers.   The reason all the terms are unified is to make it easier for people who don't spend all day coding to grasp the offerings and help them improve it.  Once I realized that, I was much less frustrated.

In fact, may of the Paypal features are innovative and unique.  The code generation features are complete.  The pages allow you to customize some of the Look and Feel, and there are REAMS of documentation.  Almost too much.

Suggestions for Paypal Developers

Here are a few suggestions for those of you who may be starting off with Paypal integration for the first time.

  •   Set up your sandbox environment and accounts FIRST.  Do this immediately.  Before you generate any buttons for production, before you get the keys for your site (or your clients site), before you do anything.  Set up a developer account in the sandbox, and set up a test client account and test merchant account right away.
  • Externalize your Strings!  This is always a good practice, but since Paypal sets up a production version and test version, and you have different URLs, account keys, account names, etc, for the production and test, it is critical that your strings are externalized so that you can easily build for test and production without having to hunt down all the configuration to change.

Monday, January 4, 2010

Creating An Android App 1 : Introduction

OK, here it goes.  I'm going to qualify this as being my first attempt at Blogging consistently.  Certainly this is my first attempt at blogging about a project, so bear with me OK?

I want to use Android to play around with location based services.  Why?  Because its pretty new and I see lots of opportunities to leverage computers in peoples pockets, that's why.  So my next few posts will be detailing the building of a simple app I'm calling, MyFriends.

This is an app that will track my location and send it to a server.  It will also send the location of all my friends to the same server, and share the location data between devices.  Initially, all the app will do is display my location on a Google map along with the locations of my friends, if they are in the maps viewable area.

This app is pretty simple, and I've seen some similar apps on the app store, but I'm doing this as an exercise to get familiar with Android.  And who knows, maybe, just maybe, this will turn into a usable app.

Things my app will need to do:

  • Get my location data
  • Send the data to a server via HTTP(S)
  • Get my friends data from the server via HTTP(S)
  • Create a Google Map view and Overlays to show the locations of me and my friends.
So, I've defined an app and the general scope of the first revision.

Next - Installation of the development tools.

Sunday, January 3, 2010

Android Development – So Easy, Yet Not So Easy

I have recently started playing around with Android. Given the success of the Droid, Droid Eris, and what looks like a phone from Google, the NexusOne, I figure the Android is going to be either the number one or number 2 development platform for mobile devices. In either case, I want to be able to write apps for my Droid, which, I love.

So this week I have attempted to start development. I have read through the online documentation, which, in typical Google fashion, is fairly complete and detailed. The Android Developer Guide includes step by step instructions for installation of the SDK, Eclipse Plugin, and samples to get you programming quickly.

Of course, nothing is perfect. So here are a couple of issues with the tools.


  • It appears that sometimes changed resources don’t get updated when the emulator is re-launched. Even though I’ve set the flag to Wipe User Data.
  • I can get one version of the Google Maps sample to run correctly but not another. It seems that the Sample Tutorial on the Web site doesn’t work for 2.0 or 2.0.1 emulators on my machine, but the sample bundled with the toolkits do. To be honest, it appears that the only difference is WHERE the MapView is instantiated, but I am still a noob at this, so I am probably mistaken

Is this going to be enough to cause me to give up? Heck no. Even though these two items are frustrating, the toolkit is still well put together and I expect to be building apps in no time. My next posts will detail the building of an app.