Saturday, August 22, 2009

Coming Up for Air

So much for posting once a month...

I've been extremely busy in my life lately, mostly due to work, which is a good thing given the state of the economy. But I'm finally seeing the light at the end of the tunnel and I think my schedule will be a little more normal in the coming weeks.

July was my one year anniversary at Art & Logic. And what a year! I've worked on 13 different projects throughout the past year, all of which I've really enjoyed. I've programmed in C++, Java, Objective C, ActionScript3/Flex, Javascript and C# (including ASP.net). I've written desktop programs, BlackBerry apps, iPhone apps (2 in the store, 1 pending approval, and some others still in progress) and a web application targeting the iPhone (and BlackBerry in the near future).
Needless to say, I'm having a blast and working as a consultant is providing me the variety I crave in a job.

One of my most recent projects, hinted at above, is an ASP.net application targeting the iPhone and BlackBerry platforms. This was my first production-level web application, although I've spent a little time on my own learning Ruby on Rails and a little bit of time at work learning TurboGears. It's been a lot of fun, and I was surprised at how much I enjoyed using ASP.net.

What I've realized during this project though, is that I really need to come up to speed on Javascript/CSS. This project was small enough that I didn't run into too many issues, but if I want to continue doing web applications (and I do), I really need a more thorough knowledge of those two technologies. I'm planning on buying some books in the near future that should hopefully give me the basics I need to build a stronger knowledge base.

I'm also hoping to provide some updates to the Grader program I developed for my brother. The deadline on that is pretty tight as his football season is rapidly approaching. So there may be a couple of late nights for me coming up in the near future.

One other project I have in mind is a simple application written on top of the Google app engine. I am a secretary for a local organization, and I'd like to create a web application that allows people to submit information to me, aggregate it, and resend it out to concerned parties. Sifting through separate emails to gather the information and compose a new email is taking up too much of my time. And it's another chance to get some web development experience.

Code Kata and Learning Math have been on hold for quite a while, but I'm hoping to get those back on track also.

Wednesday, January 28, 2009

Code Kata

One of my goals for quite a while has been starting a Code Kata practice. Dave Thomas nicely sums up the benefits of such a habit at the above link. However, there are several other reasons I want to start this practice, all of which fall under the category of becoming a better programmer, but which have materialized after starting my job as a consultant. The main factor in recognizing these areas in which I'd like to improve, has been working within very aggressive budgets (time-wise) that don't allow much time to stray from the well-beaten path.

Good Programmers Write Good Code; Great Programmers Steal Great Code
One consequence of aggressive budgets is that it usually makes sense to find existing code that does what you need it to do, rather than writing it from scratch. Between sample code in documentation, generic code from previous projects and personal blog posts, it's almost impossible not to be able to find existing code that at least points you in the direction you need to go.

Unfortunately, I think this has somewhat diminished my ability to quickly solve problems on my own. I want to use the Code Kata practice to plop myself in front of a blank editor and pull the code out of my head.

Unit Testing
Ever since taking a TDD course taught by Robert Martin, I've wanted the same experience I had in his class in my daily programming activities. Having a suite of tests to run after each code change and seeing those tests pass was very gratifying. Even more gratifying was changing the code, seeing an error, and knowing exactly where and why that error occurred because of the tests we had in place.

Most of my projects so far as a consultant haven't been very business-rule intensive. So the model objects in the code were pretty simple and the projects wouldn't have benefited that much from a unit-test suite.

The problem is, even if unit tests would have been useful, I don't have enough experience with the standard testing tools to quickly integrate them into a project without wasting valuable budget time.

I want to use the Code Kata practice to learn the different testing tools that exist, including tools that test at a higher level than a unit. I'm also hoping to get better at understanding what to test and how to write better tests.

Learning new tools/libraries/languages/specialty areas
This last point is similar to the previous one, but I also want to expand my tool set in other areas. One example is becoming an expert in a standard editor that I would use across languages in order to increase my efficiency in editor use. Another example, is focusing the Code Kata practice on an area such as Artificial Intelligence or Image Processing for a set amount of time.

Next Steps
The biggest problem in getting into this habit, like any habit really, is finding the time to do it. I know I will not be able to follow a set schedule so I will just have to be disciplined enough to dedicate some time to it every few weeks. Hopefully, posting on this blog will give me a way to stay accountable.

My first practice will be to review The C Programming Language. I already know C, but I think it will be a good way to review and give myself the pleasure of making some fast progress when I start. It certainly won't hurt to reinforce some of the basics again. And it will also give me some easy programs for unit testing, allowing some quick progress on that front.

The other thing I'd like to do during this first practice, is to learn Emacs and eventually use it as my standard editor. This will likely take quite a bit of time, but I need to start sometime. But again, it will help to start out small, reviewing a language I already know instead of taking on too many new areas at once.

Monday, January 5, 2009

iPhone SDK : UIWebView

I've been tangling with UIWebView the past couple of days and am documenting my struggles in hopes that this post may save others some time in the future. I've found a solution to my problem, intercepting single-tap events that occur on a UIWebView, although the solution doesn't seem to be optimal. But first, a little background to the other approaches I've tried...

Subclassing UIWebView/Overlaying a Transparent UIView
These approaches are basically the same. In a UIWebView subclass or in a transparent UIView subclass (on top of a UIWebView), override the UIResponder methods (touchesBegan:withEvent, touchesMoved:withEvent, etc...) and handle the touches accordingly.

The catch here for me was that I really wanted the UIWebView to behave as it always did for any other events. This would suggest that I just needed to intercept any single-tap events, and afterwards, forward all events to the UIWebView. However, what you really need to do is forward the events to the UiWebView's immediate subview, which is an instance of UIScroller. This solution seemed like it would work until I realized that pinch zoom events no longer worked and they are essential to the application I'm building.

Even more frustrating is the fact that all of UIWebView's subviews are not part of the public SDK. This fact makes it pretty much impossible to programmatically change how UIWebView works under the covers.

For more information on this approach, see the following thread in the Apple developer forums.

Overriding UIView hitTest:withEventmethod
According to Kerem at CodingVentures, he was able to intercept double-tap events on a UIWebView by subclassing and overriding the hitTest:withEvent method. However, when I implemented this technique, the UIEvent passed into the method always had an empty set of touches making it impossible to get the tapCount property on any UITouch objects. I tried overriding hitTest:withEvent for other UIView controls (e.g UIWindow, UIScrollView, etc...) all with the same result.

My Solution
The solution I came up with was to subclass UIWindow and override the sendEvent: method. This method gets called after hitTest:sendEvent returns but before any of the UIResponder methods get called. At this point, the UIEvent contains all of the associated touches, allowing me to access the tapCount property of the associated UITouch objects.

This solution isn't perfect as I am now handling single-taps at the window level instead of just those that occur on the UIWebView. Luckily, this doesn't really interfere with what I'm trying to do in my application.

I'd still really like to know why it seems that someimes the UIEvent passed into hitTest:sendEvent has touches associated with it and sometimes doesn't. I'd also be interested if anyone can successfully forward on pinch events to UIWebView.


Friday, January 2, 2009

This and That

I was able to clear my plate of several things at year's end and am looking to a fresh start to the new year. 

Job
My job is still going really well and I'm very happy with the decision I made to join Art & Logic. I've learned so much over the past half year and see that continuing into the new year. A project I completed for M Financial Group is now featured on our website as it was the first native Blackberry application completed by our company. My current project is for the iPhone and should be completed early this year.

Math
I finally completed the algebra book I started earlier this year. I have a bad habit of not quitting books I've started, even if I've decided they aren't that interesting or helpful. I probably didn't need to go through this whole book as it was pretty basic stuff. But it was a good refresher and a confidence booster that I haven't forgotten all of the math I've ever learned. The next math book I'm planning to tackle is Matrix Analysis and Applied Linear Algebra, which I know will be more challenging and should provide more value.

Grader
My brother asked for some updates to this program, namely the ability to save application session state. So I am going to add an sqlite backend to add the ability to save/reload the program data and hopefully refactor the code a little bit. I've switched over to a Macbook as my primary development machine and finally got all of the software downloaded/installed to my VirtualBox Windows image for this project. I had been using Eclipse's CDT plugin to develop this app but I'm going to switch over to Visual Studio Express since it's free.

Code Kata
I am going to write a post in the near future about how I'm planning on starting this development practice.

Blogging
I set a goal to write a post on this blog at least once a month this year. But I'm going to try and do more than that if I can.