4/05/2009
Jeff Atwood recently wrote about copy and paste coding, and those small, frequently reused code snippets that pop up at every programming blog or website.
To me, the most troubling limitation of copypasta programming is the complete disconnect between the code you’ve pasted and all the other viral copies of it on the web. It’s impossible to locate new versions of the snippet, or fold your features and bugfixes back into the original snippet. Nor can you possibly hope to find all the other nooks and crannies of code all over the world this snippet has crept into.
What I propose is this:
// codesnippet:1c125546-b87c-49ff-8130-a24a3deda659
- (void)fadeOutWindow:(NSWindow*)window
{
// code
}
Attach a one line comment convention with a new GUID to any code snippet you publish on the web. This ties the snippet of code to its author and any subsequent clones.
I’ve been idly thinking about the same thing lately, especially since I’ve started using services like gist.github to share and view small code snippets. A good example is a category on NSBezierPath to add rounded rectangles, which I remember copying from someone 5 or 6 years ago when I first started with Cocoa. If I was using this in a project today there’s no way I would remember who it originally came from, or be able to tell (except accidentally) that Leopard added the same thing when it was released and now I don’t need to use the snippet at all.
I really don’t know if GUIDs are the best (or even a workable) solution. I don’t have anything against the idea, but how can you enforce it on every blog, code sharing website, programming forum, and so on? Still, when I think about a programmer’s dream world I imagine my IDE tagging these snippets with contextual information, popping up a window with text from a blog post just like it does with autocompletion.
31/10/2008
Runner’s Log uses a license file for registration, instead of a typical 20 digit serial number. With a license file, instead of sending users a code they type or paste into your application, you send them a file that contains the serial number along with any other registration information. Usually this is just a plain text file, although it doesn’t have to be.
Lately I’ve been thinking about the advantages and disadvantages of one method versus another. Here are the major points I came up with.
Advantages
- When done correctly, license files can be easier than typing in a serial number. Just drag the file onto your app, or double click it. On the other hand, if you only require one field for your license key, and handle copy/paste correctly, serial numbers are not that much harder.
- You can include whatever information you want in you license files. You don’t want to force the user to type in their name, email address, transaction number, but there’s no reason not to include these when you generate the license. It’s good to make sure to associate a license with a real life name or email address, to discourage casual piracy.
- License files (should be) very secure. I’m not saying you can beat software piracy, don’t believe anyone who tells you you can. What you can do, is prevent someone from creating a serial number generator for your app. Unlike shared keys or cracked copies, which you can fight by releasing updates and blacklists, a serial number generator can be especially damaging. As far as I know, using OpenSSL it’s possible to create a licensing scheme that can not be beat by serial generators.
Disadvantages
- License files don’t always fit with other company’s distribution models. Right now I’m talking with a company about localizing and selling Runner’s Log in Japan, both online and in a boxed software bundle with other applications. Although I’m sure I’ll work it out somehow, they assume applications use a serial number which can be sent via email or printed out. I would guess that some of the other promotional bundles, like MacZot or Mac Heist, work the same way.
- License files can go against the way users expect applications to work, or interfere with the way they store license codes for future use. I haven’t had any specific complaints, but it’s possible some people might be annoyed.
- It takes a little more work to implement license files. You need to associate the .applicense extension with your application, implement methods for loading external files, and make sure your online store can correctly send attachments in the registration email. In my case, I also ran into some unicode text encoding bugs I had to rush to fix. None of these require big investments in time; what I’m getting at is that the little things add up, and I don’t know any developers who wished they had more on their plate right before shipping 1.0.
No matter which method you use, there’s room to make your application stand out if you put in enough effort. I remember seeing a mock-up of a license file that was actually a generated .gif or .png image. The image looked like a key card, complete with the user’s information and the license key shown as a barcode (the actual license data could be stored in embedded metadata or headers for your application to read). If you use license codes, instead of random numbers and letters you could use a series of four or five letter english words.
For the most part, license files have worked well for Runner’s Log. However, there has been a small amount of overhead that I would have rather avoided. I’m going to keep this in mind for future projects; hopefully this will help new developers who might be in the same position I was.
28/10/2008
Fundware is just one announcement from United Lemur, a company founded recently by engineer Mike Lee. The idea is for new software companies to start out with a small (but high quality) offering, such as an iPhone App. Visitors to Fundware decide to purchase the application not just on its own merit, but also on the potential of the company itself. If successful, the revenue from Fundware will give the new company capital they need to get off the ground and start producing great full-sized applications.
Most “indie” Macintosh software companies (including mine!) are started with free time and a savings account, not investment venture capital or loans. This seems like a great way to help out developers who have great ideas, but lack the time or money to implement them.
The first featured application is Puzzllotto, United Lemur’s own initial iPhone offering. Apart from being the driving force behind some great applications, Mike Lee has some lofty goals for United Lemur and how it will impact the Mac software development community— I hope he’s successful.
27/10/2008
Mike Ash on Cocoa Initializers. Great explanation of why you should use the debated self = [super init] in your Objective-C initializers. For the other side of the argument, read Wil Shipley’s take.
12/04/2008
I know it’s old, but last week I finally got around to watching Cabel Sasser’s C4[1] presentation.
Earlier this year I gave a talk (my first public presentation ever, actually!) at Johnny Rentzsch’s intimate and engaging C4[1] conference in Chicago. Despite nervousness, it was really great fun. We had just recently finished Coda, and with one hour to fill and a lot of Coda-related things still swirling around my mind, I pretty much just started talking. What followed was a whole lot of hyper-warp thoughts about all things Panic.
The presentation is great; lots of insight into the visual design process at Panic, and some of the challenges of developing Coda.
One of the more interesting parts was at the very end of the audience questions, where Cabel talks about the differences between developing a “big” application (Coda) and working on several tiny ones. Apparently the small applications each had enough feature requests and bugs that they took nearly as many resources and time as creating a larger application, only the smaller price tag meant only a fraction of the profits.
7/03/2008
The iPhone SDK has finally landed, bringing with it real Exchange support, WPA2 and other goodies. You can watch the announcement event here, or read highlights and commentary at Daring Fireball.
Although I don’t own an iPhone (yet), I did download the SDK and look forward to playing with it. My feelings about the price structure seem to be about the same as what most other developers are thinking. The $99 listing fee is no big deal. In my experience, even semi-popular freeware applications can earn back more than that through donations. The 30% Apple commission is high, but at the same time the iPhone is opening up an additional revenue source that will augment existing sales. It’s also a really neat, fun platform to develop for.
As a user, I am a little concerned about iPhone applications that are built off of their desktop alternatives. For example, if I buy a license for Delicious Library 2, will I have to pay an extra $20 for an iPhone version (assuming one is eventually released)? Will the iPhone version be free, but intentionally crippled so you need or want the full desktop version? It would be great if the iPhone version could be unlocked with a desktop serial number, but it seems like this won’t be possible. Maybe developers will be able to create coupons that will work in the iTunes store, but I haven’t heard anything about that.
I’m going to buy an iPhone eventually, I’m considering holding out until the next revision. It seems like it June would be a perfect time to release a second generation iPhone along with the new firmware update.
5/02/2008
Cultured Code writes about designing the user interface for creating repeating items in their upcoming task management application, Things:
It seemed fine in theory. But after implementing and combining it with the underlying logic, it took us only minutes to discover that it didn’t work as expected. Not that anyone was able to tell exactly why. And that’s often the case when developing user interfaces. It just didn’t feel right.
Looking at the sheer number of rejected designs, it’s no wonder why Things is my favorite task management tool at the moment.
31/01/2008
I should have mentioned this a long time ago, but Cocoa programmer Mike Lee has started a charity to save Madagascar lemurs. Prior to reading I had no idea lemurs were in danger of extinction or the good even a small donation could do, but Mike makes some very convincing arguments.
Instapaper is a new web application for saving links to websites you want to read later. It’s simple and fast, and it’s replaced the .webloc files scattered around my desktop.
Iconfactory released version 2.0 of xScope, a toolset for designers that makes it easy to measure or align visual elements on the screen. It’s extremely handy when doing web design.
Tentacle Arm. Who doesn’t want one?
7/12/2007
Great writeup from Daniel Jalkut on examining crash logs with the atos command line tool:
Many developers seem to think that gathering useful crash logs requires shipping a symbol-laden application, but aren’t willing to do so. The fact is, you can have the best of both worlds by shipping a symbol-stripped version of your application, but keeping a symbol-laden version on-hand for the developer’s convenience.
What am I getting at? Apple offers a tool called “atos”, which makes it relatively easy to map an address from a symbol-stripped application to a name in a symbol-laden version of that same application. As long as the two applications were built with the same sources and using the same build options, the addresses are bound to match up. It’s just the symbols that are “stripped” from the shipping application.