Monday, July 6, 2009

The Wite Box Project

The Wite Box Project is an open source unit-testing framework designed and implemented specifically for iPhone. I started this project in response to the existing solution, the SenTesting Framework, which I find below par for a variety of reasons.

Here are some of the features of Wite Box and how I believe they improve on what exists today:

Visual Results in a Native iPhone Application

As a devout TDD developer, I have become somewhat addicted to the "green bar." Unit-testing devotees know what I mean. To see that beautiful green bar, perhaps after a few iterations of the nasty red bar, to soothe you, to tell you it's OK, to confirm all your beliefs that your code is sound and correct. Oh, what a feeling. But the SenTesting Framework took that away from me. My only positive feelings come from a *lack* of build errors (which are really unit test errors). It's just not enough for me. The results are displayed in a native iPhone application. That's right, this system was build for iPhone development specifically. As the iPhone SDK grows, so can Wite Box right along with it.

Navigable Test Results

The most annoying thing I find about the SenTesting Framework is that unless you read the compilation console -- and who on Earth wants to keep that thing open?? -- you can't really know if your unit tests were run at all. This is a noticeable omission as it's a very common mistake by developers to think their tests are being run when they are not. This becomes a problem when you are getting success back, and you assume your unit tests are good, when in fact they never ran at all!

Wite Box displays all your test cases, and unit tests, in a navigable UITableView. The successful tests are green and the failed tests are red. Failed tests can even show you what went wrong. It's very easy to see the results of every test you've added, but most importantly you will easily know which tests have run in the first place!

Expanded Hooks

I've always wanted wanted more hooks to add to my test case. xUnit has historically included setUp() and tearDown(), methods that run at the beginning and end of every test. Sometimes, though, I want a little more control. Wite Box provides it. There is still setUp and tearDown, but these now are run before and after the test case in its entirety. Now, you can set up just one database connection, or open the contents of just one file. Once. In addition, there is setUpTest:(SEL) and tearDownTest:(SEL) which not only run before and after each unit test, but pass along the method that will get called in case you want to have more custom initializations. Test cases also let you define a (BOOL)isEnabled method so you can enable and disable test cases programmatically.

Easy Setup

One good thing about the SenTesting Framework is how easy it is to set up. Aside from the fact that test cases fail if you haven't added any yet, it's pretty easy to add test cases and have them run. Wite Box preserves that ease. The setup procedure takes just a minute for Wite Box, and by the end of it you have a running application that runs your unit tests and gives you all your results in a clear display. Don't worry about messy setups or broken code!

What's Coming

The Wite Box Project is a work in progress. Currently, at v0.92, it works for synchronous test cases and all the hooks are there. Soon, however, it will be expanded for asynchronous support and an expanded set of asserts, including Hamcrest.

Getting Started

If you're ready to get started, head over to The Wite Box Project and check out the Wiki documents on Setting Up Wite Box and then Writing Unit Tests. We hope you enjoy our unit testing for iPhone!!!

Thursday, June 25, 2009

Task List for iPhone

Yesterday, I submitted Task List, my second iPhone application, to Apple for review and acceptance on the App Store.

Task List is a To-Do List application born from my desire to find the perfect one. In the end, none satisfied me, and the best one cost $9.99 which is just ludicrous considering I didn't need much to be satisfied. With Task List, I made an app I absolutely adore for my own use -- and I haven't felt that way about something I made since I made Jabber and Morphy Chess for BeOS many years ago. ;-) In a couple weeks it will hopefully be approved and available for just $0.99! Buy it early, because the price will go to $1.99 with the second release!

Wednesday, June 17, 2009

iPhone Provisioning Frustration -- Solutions?

As many iPhone developers will tell you, provisioning an app for a device is a nightmare. The process, though esoteric at first, is actually not that difficult to understand after you go through it a few times. What IS absolutely unnerving is that the process is so fickle and often-times fails for no discernable reason. So, here are a few tips in case you run into issues:

  1. Be sure to install in this order: (1) mobile provision to XCode (you will see a warning if steps 2 and 3 have never been done before), (2) Install the WWDC certificate, (3) Install your certificate.
  2. Be sure to drag the provision into both area in Organizer.
  3. Clean and build, restart XCode, or even reboot before going too crazy. It's annoying.

Tuesday, April 7, 2009

Beta: Code Cram

I've been working on a little project for a little while now called Code Cram. I'm actually designing it for a very important customer of mine:

Me.

The goal is to create a system that allows me to easily jump from language to language with minimal "refresh." I also aim to eliminate the language from the competent developer's skill requirements. To become great developers, we need to focus on great design and execution and not spend meaningless brain cycles recalling how to implement the language.

The hope with Code Cram is to build a reference guide that's between a cheatsheet and a book. It's designed for the developer that knows the language already, but because they must go between so many languages, it can get confusing to remember how to perform even some of the simple tasks.

Over the next weeks and months I'll perfecting the ActionScript material on Code Cram and authoring the reference for the other languages. I'd love to hear feedback. So check it out and let me know how it goes. :-)

Saturday, April 4, 2009

Git Archive

One of my favorite commands is to archive via Git. A perfect way to send a moment in time to someone in source. What better way to say I love you? :-)

git archive --format=zip --prefix=source/ HEAD > source.zip
The result is a clean snapshot of the Git source tree. No dot-files, no CVS/ folders, none of that. Just a clean ZIP of the source.

Wednesday, April 1, 2009

Fixing Cyberduck Directory Listings

I've noticed this problem, off and on, for a long while now. Finally, a fix. Because Cyberduck uses several possible ways to list a directory, it cane sometimes get stuck. Running this on the command-line fixed everything for me and could help you too:

defaults write ch.sudo.cyberduck ftp.sendStatListCommand false
More info here.

Tuesday, March 31, 2009

jQuery: Extended Text w/ "More..."

While jQuery is great with special effects, sometimes the best UI improvements come from the simplest features. Today, I'll show you how to maximize the real estate for your Web site by cropping text behind a "more" link...

If you don't care to read about it, you can see the example.

A "more" link shortens large blocks of text that not all users may want to read. Click the "more" link at the end of this sentence to see an example. (more...)See? Now you can see the extra text! That's all a "more" link is. If, as a user, you are interested in the text then you can click to see all of it. For the rest of the readers, they can choose to ignore it and don't need a huge paragraph interfering with their locus of attention.

Before I show you how it's done, let me just say that there are no less than a MILLION ways to do this. This is one way. :-)

First, we need some markup. Here's what our HTML will look like:

<p>Four score and seven years ago our fathers brought forth on this continent, a new nation, conceived in Liberty, and dedicated to the proposition that all men are created equal. <span class="more">more...</span>

<span class="hiddenText"><p>Now we are engaged in a great civil war, testing whether that nation, or any nation so conceived and so dedicated, can long endure. We are met on a great battle-field of that war. We have come to dedicate a portion of that field, as a final resting place for those who here gave their lives that that nation might live. It is altogether fitting and proper that we should do this.

<p>But, in a larger sense, we can not dedicate -- we can not consecrate -- we can not hallow -- this ground. The brave men, living and dead, who struggled here, have consecrated it, far above our poor power to add or detract. The world will little note, nor long remember what we say here, but it can never forget what they did here. It is for us the living, rather, to be dedicated here to the unfinished work which they who fought here have thus far so nobly advanced. It is rather for us to be here dedicated to the great task remaining before us -- that from these honored dead we take increased devotion to that cause for which they gave the last full measure of devotion -- that we here highly resolve that these dead shall not have died in vain -- that this nation, under God, shall have a new birth of freedom -- and that government of the people, by the people, for the people, shall not perish from the earth.</span>

Next, you need some CSS. This will bring it together for us. Here's what it looks like:

 <style type="text/css" rel="stylesheet">
  .more {
   text-decoration: underline;
   cursor: pointer;
  }

  .hiddenText {
   display: none;
  }
 </style>

And now, your jQuery:

  $(function() {
   $('.more').click(function() {
    // make the more link hidden
    $(this).addClass('hiddenText');
    
    // unhide the extended text
    $(this).next().removeClass('hiddenText');
   });
  })

And that's it. The jQuery simply transfer the hidden status from the extra text to the "more" link. View the example here.

Friday, March 27, 2009

We Need a Unified Language

On 3rd Rock From The Sun some years ago, in the first season, there's a scene where Harry is raving about having the Telemundo channel on cable. Dick starts ranting back at him in spanish, and then Sally and Harry continue the discussion in perfect spanish as well. As they argue and shuffle out of the house, Dick wonders aloud, still in spanish, what language they speak in Ohio and that's when they figure it out and revert back to English. As they go down the stairs, laughing about it, Dick sarcastically exclaims, "Earth!" I still miss 3rd Rock, but the point of the scene is that it's kinda funny that we all live on this tiny little planet, and yet there are thousands of different languages and dialects we're speaking. Just imagine an Earth where we all speak the same language. Just imagine what an unhindered flow of ideas would result in? Maybe it sounds silly, but it's entirely possible that removing the language barrier could produce a cure for cancer faster, fully intelligent software systems, a time machine? Laugh. Sure. But, how does this relate to software development? Let me speak about myself for a moment. I'm a Flash/Flex developer full-time, a Java ME developer part-time, a jQuery enthusiast, and every so often I break into some PHP. What annoys me more than anything is that when I switch from language to language, I constantly have to re-solve problems in language-specific ways. It drives me insane. It's so hard to keep everything in my head, and I rarely can. I have a set of reference material (books, links, etc.) that I rely on when I need it. Just the other day, a colleague asked if there was a way to set a cursor position in a text field in Flex. I was sure it had to do with selectionIndex beginnings and endings. When the field I quoted wasn't found, I started to believe that it was old VB knowledge I was recounting. Or was it Java AWT? Well, we figured it out, but boy it peeved me that it's just about impossible to keep it all straight. It wasn't always this way for me. I used to be a Perl guru. All I needed to know was Perl and maybe a little SQL. Every expert-level practice in Perl I knew. It was my world. My book library was a camel book and a panther book (Perl'ers know what I mean). A new release of a Perl book was exciting, a way to build on a masterpiece of near-perfect knowledge. Screw that now. I'm lucky if I go just a few months without having to learn something new. Here's a typical developer bio:

Two years ago I was working on legacy ActionScript, AS1. I taught myself AS2 so I could do some job interviews to help get me out from under this obsolete platform, but didn't land anything. Then AS3 came out. However, I was learning Ruby on Rails to try to get somewhere new. After building a site, I realized PHP was too mainstream, so I changed to it. Then, my company moved us to JSF and I had to not only refresh on Java, but learn the Spring/Hibernate platform as well. My HTML was ancient, so had to learn the newest things, including some decent CSS. And, oh man, look what JavaScript does not -- what, it's ECMAScript? I'll learn that. Wait a minute, I need to learn AS3 to do Flex? Don't make me do Flex, I don't have time to learn ANOTHER LANGUAGE!!!
The madness must stop! What we need is a unified language. Think about it. What separates ActionScript, JavaScript, PHP, Ruby, Java, and even C#? The languages are all pretty similar, except maybe Ruby. What separates them is the libraries. And then, even there, they are mostly the same. What would be nice is that if someone makes a better Web framework, like Rails, that I wouldn't have to learn a new language (Ruby) to use it. Look at the PHP community right now. While all the PHP developers are in denial of Ruby, they are all trying to replicate Rails. All of these great programmers putting tens of thousands of hours into creating dozens of new frameworks, but Rails already exists. Imagine we could get their brainpower working on problems that HAVEN'T been solved yet? My father-in-law is an ex-Lockheed Martin employee. He says they still use C to program most of their systems. (There's some Java being introduced, too.) Why C? The theory is that why should they keep changing languages and starting from scratch in their knowledge? They have super-duper C experts there now as they've been using it for decades. If they switched to a cool language like Ruby, what with all their fancy lambdas, all that C expertise is lost. Gone forever. And the gotchas of a new language are then more likely to strike in some engineering disaster. Imagine there was one language, and improvements were made to it over years. Imagine there was only one language. And when some developer somewhere made a great hashing library, or a super-fast XML parser, EVERYONE benefitted, not just the users of that language. And, instead of having a language lapse after a few years, and that great work lost to time, what if it never went away. What if software perfection were possible and we could stop re-writing the same stuff over and over? I used to be jealous of Ruby or Perl programmers who had nifty language features that an ActionScript programmer like myself didn't have. AS3 is an AWFUL language. It's only "clever" features are a few functions in Array to do mapping and such, and even those are so cumbersome to right I don't know anyone who uses them. Why oh why does ActionScript always have to try to mirror JavaScript? But, now I get it. The Flash or Flex programmer is a Web programmer! They likely already know JavaScript! And that's why when I do JavaScript work, it's not as painful. The constructs are the same. And if I run across a feature I wasn't familiar with, like with, I know what it is because ActionScript has it! So, maybe Macromedia/Adobe got it right. Stop reinventing the language. We speak in applications. We converse in innovation. We use language. What do you think?

Thursday, March 19, 2009

I'm on SlideShare

I've posted some presentations of mine on SlideShare. They look a little weird because SlideShare is munging something up with the complex background. I'll fix it for my future presentations. Currently, you'll find Intro's to Mate and Test-Driven Development, but keep an eye out for some advanced Mate stuff and jQuery!

See John Blanco's presentations.

Saturday, March 14, 2009

How to get a bookmark icon (favicon) on your site

Every serious site should have a bookmark icon, AKA favicon. I mean, have you ever looked at your favorites and out of a group about ten sites, one doesn't have an icon? I confess, I have sometimes deleted bookmarks because it bugged me so much. :-) And it's so simple to do, it's sad that every site doesn't have one. First, let's take a quick look at how it originally worked. It was pioneered by Microsoft, and involved simply adding a file, /favicon.ico, on your server. There were some issues with this, notably that it only worked when a site was bookmarked, and obviously that you have to use the ICO format...which is, like, what? The good news is that you can put the graphic anywhere now, and you can simply set up a link to it on all your pages...therefore every page can have its own icon. The bad news is that, even though you can use a PNG or GIF now, you still want to use ICO because that's the only format IE understands. Freaking IE! If you have Windows, you can use IconEdit32. If you use a real OS like Mac OS X, give icon2ico a shot. Then, hook up the following HTML to whatever page you want an icon for:

<link rel="icon" type="image/x-icon" href="http://raptureinvenice.com/favicon.ico"/>
]Change the type attribute to whatever MIME type you're using (e.g., image/png) and, of course, set the href to what image you're using. Note that I like to keep my icon in old, traditional place -- for the really old browser, and besides, why not? Also, use an absolute URL, too. It's just safer that way. Happy icon-ing!