Archive for June 2009

CodeStock 2009, Day 2

Here were the sessions that I attended on day 2 (Saturday, June 27, 2009) of the CodeStock 2009 developer’s conference in Knoxville, Tennessee:

Keynote by Josh Holmes

Finally, someone in the software development realm that values simplicity as much as I do…

Getting Started With WPF by John Kellar

John gave a very introductory presentation on developing applications in WPF, which seems to be the way that desktop client applications are going to be developed moving forward due to (among others) resolution independence and performance of WPF apps. The talk was pretty much devoted to a tour of simple application creation and layout in Visual Studio 2008 and Expression Blend, both by using the control toolbox and by manually manipulating the XAML. Along the way, John mentioned some interesting items, such as avoidance of the CanvasPanel, using Alt-Shift-Enter to go full screen in VS 2008, and the Microsoft web site WindowsClient.net, which is devoted to WPF application development.

ASP.NET Web Testing by Jeff McWherter

Jeff talked about aspects of testing web applications, with an emphasis on the tools that can make testing ASP.NET web sites easier and more automated. The tools he demonstrated were NUnit, WatiN, WatiN Test Recorder, qUnit (for Javascript), TestDriven.net, and Selenium. Also, Jeff showed briefly the System.Diagnostics.Stopwatch functionality, and talked about accessibility testing using the webaim.org web site.

Be A Better Developer by Michael Wood

Mike covered his theories on improving the craft of software development, and I agree with most of them. All developers need to be students and teachers first and foremost. The student part means learning about new technologies and gaining a thorough understanding of them, especially the fundamentals. The mentoring aspect allows the sharing of knowledge and experience, which benefits the entire team. His recommended reading is Getting Things Done by David Allen, and some of the tools he believes in are WinMerge, MSBuild, and Power Shell.

jQuery 101 by Rod Paddock

Rod covered an overview of jQuery, including initialization, selectors, events, and plugins. Again, being the Javascript neophyte that I am, I thought the presentation was very good and should help me figure out some of the mystery happening in these .js files in our web application project. Some of the things I found interesting were the jQuery UI, using $().focus(selectOnEntry) to automatically select text in a text box when the cursor reaches it, highlighting on focus and unhighlighting on blur, and using a div tag to display dynamic HTML.

How To Make Your Application Awesome With JSON, REST, and WCF by James Bender

James talked quite a bit about web services and using jQuery to consume them. At this point of the conference, I was a bit spent, to I did not take many notes about this presentation. The only notes I made was when he was talking about the Fiddler web debugging proxy. Hopefully, James will post his slides and sample code to refresh my memory.

Day 2 was also Javascript heavy, and I found the WPF presentation highly relevant, since we have a lot of desktop client applications in our line of business, and the WinForms applications are looking a bit dated.

A special thanks and shout out to Michael Neel and his staff and all of the presenters and sponsors on a job well done.

CodeStock 2009, Day 1

Here were the sessions that I attended on day 1 (Friday, June 26, 2009) of the CodeStock 2009 developer’s conference in Knoxville, Tennessee, along with what I thought was important, relevant, and/or clever:

Javascript Makes Me Happy! by Joe Bowers

Joe covered Javascript basics such as dictionaries, arrays, functions, event handlers, and closure, all of which were informative and useful for me, since I am a Javascript dummy. The iteration stuff at the end was a bit mind blowing, it will take me a while to figure out what was going on there, as it seemed to combine all of the above concepts.

Useful jQuery tips, tricks, and plugins with ASP.NET MVC by Elijah Manor

Elijah talked about a couple of interesting looking jQuery plugins such as TableSorter (which we are using) and xVal validation. I hope that we might be able to integrate the xVal stuff into our web application, even though we are not using ASP.NET MVC. Also, he pointed out some interesting tools, such as Firebug, PageZipper, Detect Plugins, and SelectorGadget.

Programming the Cloud with HTTP/REST by Mike Amundsen

Mike showed some very cool Javascript/web service demonstrations, along with a lot of talk about the theory and operation of HTTP and REST. It was a lot to take in for a novice web and Javascript developer. I just hope I can get some of his samples (for starters, the zip code checker) working on my box.

iCode: An Intro to iPhone OS Development by Adam Byram

Adam ran through a high level introduction of many of the concepts involved with iPhone software development, such as the tools required and overview of Objective-C. Then, he went through and began coding from scratch a to-do list application.

It was a Javascript heavy day, which is good for me, since I used to have no idea what some of my coworkers were talking about in our web application.

Can you recognize me now? Good.

OK, so a coworker and I are getting ready to hit the road and head down to Knoxville, Tennessee, for CodeStock 2009. Our company has two Verizon Wireless broadband USB cards that we use for presentations and such, so I procured one as I have done in the past to use in Mac and Boot Camp Windows mode on my MacBook Pro. Little did I know the trouble I was headed into getting it all to work on both the Windows half of my MacBook Pro and on my coworker’s Dell Vista notebook.

I had Verizon Wireless Access Manager (cleverly acronymed to VWAM) version 5.8.2 on my MacBook from my previous experience with a Pantech CDMA UM150 card from Verizon. I fired up the software, tried to use the card I was given (a Novatel Wireless EXPD EV720), and it was not recognized. Here is what happened next:

  • Uninstalled VWAM 5.8.2
  • Downloaded VWAM 6.10.2 from Verizon’s web site
  • Installed said software
  • Tried to run VWAM, connected device, no-go

At this point, I decided to try and get a bit creative, think outside the box as it were:

  • Tried to run the NvtlDriverCDFilter_V2.02.07.002.exe application, which I found in the folder C:\Program Files\Verizon Wireless\VZAccess Manager\Drivers\Novatel
  • This component must have already been installed (perhaps by the VWAM 6.10.2 installer), but I went ahead and did the removal
  • Automatic restart
  • Tried to run VWAM, connected device, no-go
  • Ran the NvtlDriverCDFilter_V2.02.07.002.exe application
  • Tried to run VWAM, connected device, no-go

OK, so now I am getting a little perturbed. Time to break out the big guns:

  • Launched Device Manager
  • A yellow exclamation point is showing next to a Data Interface (a-ha!!!)
  • Right click on Data Interface, select Update Driver, and let Windows handle the driver update automatically, at which point the yellow exclamation point disappears
  • Tried to run VWAM, connected device, hardware reported as ready to use and the Next > button lit up.

And it is now working fine on the Windows half of my MacBook Pro.

Armed with this knowledge, I went to my coworker and had him do roughly the same thing. He had an additional snafu on his machine, however. Toward the end of the NvtlDriverCDFilter_V2.02.07.002.exe installation procedure, it came up with an error:

Error 2738. Could not access VBScript run time for custom action.

We did some investigation and found a posting in the support database for NitroPDF that seemed to address this error:

Q10106 – ERRMSG: Error 2738. Could not access VBScript run time for custom action. EDIT: Sorry, this link appears to have been removed from the NitroPDF web site. 🙁

After registering the VB Script DLL, and running the installer again, and running the VWAM on his Dell, the card seems to be recognized and connects fine to the Verizon network. Celebrate good times, come on!

By the way, I hate to make this sound like one of those “Hello, I’m a Mac/And I’m a PC” commercials, but the card ran smooth as a baby’s bottom on the Mac OS X half of my MacBook Pro. No software updates or driver snafus whatsoever.

Stanford iPhone App Programming lecture 8

Lecture 8 from the Stanford University iPhone Application Programming class was hosted by a guest speaker from Apple. The topic of the day was tables and table view controllers. Again, there was lots of good information in the class. I have not really worked yet with tables in my iPhone application development so far, but I’m sure once I do, this information will help out.

When 5.95 does not equal 5.95

People like nicely formatted numbers on their reports and web pages. For example, if I needed to display the results of a division where the dividend is 1 and the divisor is 3, typically I would display that as 0.3 (the number formatted to 1 decimal place) instead of 0.3333333.

So imagine my surprise when I had a single detail line in my report where a value is shown as 6.0, but in the total line right below it (which utilizes the same data since there is only the one detail line), the same value is displayed as 5.9.

We finally tracked the problem down to a conversion between a float to a double. It appears that the .NET runtime is not able to take a float value of 5.95 and convert it exactly to a double of 5.95, the conversion sets the double to 5.94999980926514. As a result, when this value was sent into the string formatting function, the value would round down instead of rounding up. Keep in mind that the divisions actually come out right, whether they are floats or doubles. As I stepped through the code, all looked well since the float variable was calculating as 5.95 (119 divided by 20), but this was of course before the conversion and formatting.

As I think about it, I was pretty lucky to find this little glitch, as it will only manifest itself when for certain dividends when the divisor is a multiple of 20. (The 1 decimal place round off error happens at multiples of 0.05, or 1 / 20.) Feeling interested, I decided to do a little experimentation. I am married and over the hill, what else am I going to do on a Friday night?

I set up a .NET C# console application to test out the divisions, conversions, and string formatting, and reporting on when the formatted string of the double varies from the formatted string of the float converted to a double. The divisor would loop from 20 to 1000 by 20, and the dividend would loop from 1 to 1000. The final results were:

Divisions tested: 50000
Divisions failed: 916
Failure percentage: 1.83 %

As expected, the divisor of 20 shows the most variations, and dropped off to only 4 variations with a divisor of 1000 (at 350, 450, 650, and 950).

The moral of the story is when it comes to floats, just say no. We went into the code and removed all the float variables and casts and changed them all to doubles.

Stanford iPhone App Programming lectures 6 and 7

Lectures 6 and 7 from the Stanford University iPhone Application Programming class contain a lot of useful information regarding the theory and usage of view controllers in general and navigation controllers and tab bar controllers in specific.

It took a bit of digging to figure out what Evan Doll’s shirt said in lecture 7, but apparently there is a band out there called Blitzen Trapper.

CodeStock 2009

CodeStock 2009 is rapidly approaching, and an associate of mine at the office is attending this year’s conference with me. If you happen to be attending the conference, and notice a loud troublemaker somewhere in the vicinity, it would be my associate. Just be careful giving your business card to him, he is likely to use one of them for his only phone call, as I told him that if he needed bail money, he is on his own.

VB.NET ListBox does not scroll all the way to the bottom when setting SelectedIndex

I have a standard Windows list box that I am using in my Visual Basic .NET application. I am adding records into this list box by binding it to a data source that reads records from a local database and uses a display member in the class to chew on the record and spit out the text. Then, I logically want to see if there are records in this newly minted list box, and if so, set the selection to the last record in the list, which should scroll to the bottom of the list in the event that there are more records to display than lines in the list box. The code:

lstRecords.DataSource = DataLayer.GetRecords(theID)
If lstRecords.Items.Count > 0 Then
    lstRecords.SelectedIndex = lstRecords.Items.Count - 1
End If

Unfortunately, this code does not work 100% as expected. If there are more records than rows available in the list box, the final row does get selected, as the blue selection bar lands on that row. Once you scroll the list down one row to see it. For some reason, the scrolling down of the list box comes up one row short when done this way, no matter how many rows beyond the limit of the list box are added.

I tried everything I could think of, mostly manipulating the properties of the list box to see if some combination worked. I called the Update and Refresh methods, set the TopIndex and IntegralHeight properties, and lots of other things that did not have any effect.

I finally decided to try to set the SelectedIndex property in a timer event. The timer is initially disabled with an interval of 5 ms, and instead of setting the SelectedIndex property as shown in the line above, it enables the timer. And here is the code that executes when the timer fires:

tmrScrollToEnd.Enabled = False
lstRecords.SelectedIndex = lstRecords.Items.Count - 1

And of course, for some reason that escapes me, this now works. Perhaps it is because the setting of the SelectedIndex is moved outside of the Form Load code, which is where the code above was being executed. If anyone has any ideas, I would love to hear them, but I am glad that it is now working.

Stanford iPhone App Programming lectures 4 and 5

I just finished going through lectures 4 and 5 of the iPhone Application Programming class from Stanford University, and learned some more new things that I did not know. Especially interesting was the Stalker demo application that they did at the end of lecture 5, it was kind a neat little demonstration of animating views.

A whole year of more randomer-ness

Today is the 1 year anniversary of a snippet of our company’s code being featured on The Daily WTF web site.  Here is a direct link to the article so you too can bask in the goodness of real randomicity:

More Randomer

So I bought cupcakes for our dev team and decided to hack one of the cupcakes:

More Randomer's First Birthday

By the way, the developer that created the code in question is no longer at the company.