Sunday, December 15, 2013

From concept to reality in 6 weeks - part 21

Yesterday I took the day off and read a book "The Mountain of Light" by Indu Sundarsan which is a different view on the same story that my favorite author William Dalrymple wrote about called "Return of a King". It was very relaxing to take a whole day to read this 300+ page book.

I definitely did not intend to work today, but when I found out that due to budget constraints I would need to finish this week. Running out of money is one of things common things in life that we just have to deal with. In a perfect world, I could just go on forever writing stuff that the customer wants but someone has to pay for the work being done and in this case, as in all of the cases I have work on,  there is limited amount of funds.

My goal today was to allow multiple server requests to retrieve data for at least 24 hours and have it show up on a map. Seems like a reasonable thing to do since I have to have that working by Wednesday.

First I was curious about a couple of things I have seen in sample code. What is the difference between strings surrounded by double quotes and those with a "@" preceding the double quotes? That was easy to find the answer as it was the first match from Ms. Google as it is called Regular vs. Verbatim strings. The next question is about regular expression string matching. I found a page outside of MSDN that was a helpful start on C# regular expressions. I found good documentation that showed me that it is exactly as I expected. The regular expression quick reference was what I needed.

As I started coding I quickly did something evil again as I kept getting a run-time null exception. Man those are so hard to track down. I went back to see if there was a way to capture every exception and tried both "catch (Exception e)" and an "catch" without any exception. There was something I was missing as one of my asynchronous calls must have gotten me in trouble as I could not track it down. I did learn to that there is an easy way to show the class name in debug statements by using "this.GetType().Name" as that was definitely helpful. One other thing I was a bit concerned about was extending an array as more data became available, but I learned that was no problem as a List can be changed on the fly by either increasing the Capacity or just adding more elements one at a time.

I decided it was time to completely rewrite the complex code I wrote that gets data from a server. The Background Transfer code I wrote was way too complex to debug and was causing too many issues. I went back to the drawing board to learn how to use the HttpClient in a Windows Store app. My code was just so much clearer in the end and actually worked to transfer 24 hours worth of data in 1 hour increments. I was so happy I had to send screenshots to the customer even at the late hour it is.

This post clearly does not cover everything I did as it took me all day long to rewrite my code, so the number of words in this post clearly does not express how much I got done today!

No comments: