A Different Type of Optimization

December 31st, 2013

For years I’ve heard the mantra from Apple engineers of not optimizing prematurely, because you never know where your bottlenecks actually are until you profile the running code.

But that’s only one type of optimization.

I, for instance, always optimize for project size.

Expand one of my projects and you’re unlikely to find more than 30 or so class files (counting header and implementation files as one.) Yes, it makes for bigger individual files, but it also makes for a much more easily digestible project tree, and, more importantly, it makes for MUCH less jumping around between files when debugging some complex process.

Over the years I’ve dealt with many applications that send http requests and receive responses. The first thing I do when I inherit one of these projects is to expand the entire project tree to see just what I’m dealing with. Often I find a project consisting of literally hundreds of files, many only a few lines long. One or more class files for every single business object, specialized classes for abstract concepts, multiple classes for implementing a single process, etc…

AAAARRRRGGGGHHHHH!!!!

It has not been unusual for me to see a process flow something like this:

 

User does something that requires calling a web service.

Method 1 in Class A creates a new request object and passes it to Method 2 in Class B.

Method 2 in Class B calls Method 3 in Class B to get info with which to populate the message header.

Method 2 in Class B calls Method 4 in Class C to get the body info for the request.

Method 2 in Class B passes the request to Method 3 in Class D to format the request.

Method 3 in Class D calls Method 5 in Class E to Sign the request.

Method 3 in Class D calls Method 6 in Class E to encode the request.

Method 3 in Class D passes the request to Method 6 in Class F for sending.

 

So we have 6 methods in 6 classes just to send out an http request.

Then there’s the response…

 

Method 1 in Class A gets the response object.

Method 1 in Class A passes the response to Method 2 in Class B to parse.

Method 2 in Class B calls Method 3 in Class C to parse the header.

Method 2 in Class B calls Method 4 in Class C to parse the body.

Method 2 in Class B creates an instance of (business object) Class D, initializing it with the body of the response.

Method 2 in Class B passes the instance of Class D to Method 5 in Class E, which is the final recipient of the result.

 

So we have 5 methods in 5 classes to handle the result of the http request.

All total, that’s 11 methods in 11 Classes to handle an http request/response. Well… up to 11 Classes, as there could be overlap in classes between the send and receive processes.

And this is just the norm. I’ve seen some projects which easily double the number of methods and classes touched in implementing this request/response.

Now, let’s say you need to trace a request/response from start to finish. You’re jumping around to 11 methods in 11 files. If there’s a problem somewhere you’re trying to debug, and you’re in an IDE that keeps a tab open for every file you hit, you now have 11 tabs open for the 11 files you touched while tracing through this process. If bad data is occurring somewhere, you have 11 breakpoints in 11 files to try to find it.

When I have to debug the above, I roll my eyes and breath a sigh of aggravation at the developer who designed it.

Let me compare that to the actual process I use in Snap That! for implementing http request/response:

 

User does something that requires calling a web service.

Method 1 in Class A creates a new instance of Class B .

Method 1 in Class A calls Method 2 in Class B with the data needed for the request.

Method 2 in Class B creates the http request, formats it and sends it.

Framework Method 1 in Class B receives data and builds response.

Framework Method 2 in Class B sends response back to Method 3 in Class A.

Method 3 in Class A parses the response and uses the results.

 

So we have 3 methods (not counting the framework methods required to receive and package data) in 2 classes.

Debugging this process? Simple. Simple. Simple.

The usual objection to doing things the way I just outlined is that it results in unmanageably large source files.

Checking the file for the class I use to process http requests, it has 997 lines (and I put brackets on their own lines and use blank lines liberally for visual clarity) to handle 23 distinct web service calls. I don’t find that to be unmanageably large.

Yes, the two processes aren’t exactly equivalent, but basically there are three things I do that limit the amount of jumping between methods and classes in this process:

 

1) Using one DataManager class that handles all outgoing and incoming data requests and responses.

2) Inlining the code in one method that creates the request, formats the header, formats the body and sends the request.

3) Parsing the response into a framework-native dictionary class instance instead of creating instances of custom business object classes for every response.

 

The moral: separation of concerns, encapsulation and modularity are all fine OO concepts, just don’t overdo it.

 

Gold Runner for iOS now an Open Source Project!

January 14th, 2013

In the past I have been accused of having a career based entirely on one game: Gold Runner. It might actually be true.

Gold Runner was a game written for the TRS-80 Color Computer in 1984. It bears a striking resemblance to a game called Lode Runner for the Apple 2 and other 8 bit computers of the time.

It also happens to be my favorite computer game of all time. I’ve always had an obsession with the game and it’s never been far from my mind when contemplating game development of my own.

So in 1994 I finished Gold Runner 2000, a version written for the MM/1 personal computer.

The MM/1 would most accurately be described as a hobbyist computer bought by a number of members of the Color Computer (CoCo) community after the Color Computer 3 had become dated, the rest of the computing world had moved on from 8 bit to 16 bit systems, and Tandy had failed to provide such an upgrade path for the CoCo.

Gold Runner 2000 maintained all of the play mechanics from the original, but increased the size of the graphics images such that a whole level took up the size of 9 screens. This means that Gold Runner 2000 was a 2D side-scrolling game.

Color Computer (and MM/1) enthusiasts used to gather periodically for conventions, or “Fests”. And I took Gold Runner 2000 to just such a Fest in Atlanta soon after it was done.

From that exposure, I met a number of people. A couple of them worked at a company called Microware. Microware developed the operating system (OS-9) that ran on the MM/1 and Color Computer 3. When Microware needed some new developers with OS-9 experience, one of my new friends, Boisy Pitre – Microware employee, thought of me from having known my work on Gold Runner 2000. He contacted me, and it just so happened that I had just graduated from Arizona State University with a degree in Psychology. I worked for the credit card division of Chase Manhattan Bank, and prospects for a career with a basic liberal arts degree were pretty slim. So I took the job with Microware, in Des Moines, Iowa.

Almost two years later, I left Microware, moved back to Phoenix, and through a series of lucky occurrences and knowing the right people, continued working as a programmer despite not having the appropriate degree.

So yes, Gold Runner is responsible for me having a career in this field today.

Now, in 1997 I was moving on from the CoCo, fully entrenched in MM/1 development, and I missed my favorite game. So I decided to write a clone of the original CoCo Gold Runner for the MM/1. I played through every level of the original game, mapped each level out by hand on graph paper, digitized all of the sounds from the original, and re-created the (very simple) graphics from the original.

And, I must say, I did a damn good job. I recreated every aspect of the CoCo original. I copied the high score screen exactly, with the graphical effect of the line for the current high score alternating between white-on-black and black-on-white. I copied a graphical glitch from the original that, when a character was on the far-left edge of the screen, displayed the leftmost pixel of that character on the right side of the screen, one pixel lower than it would have been had it displayed properly on the left side. And finally, I recreated the oval-shaped fade-in feature of each level as it started.

High Score Screen

Game Screen with Oval fade-in

I decided that I didn’t just want to create a Gold Runner game, I wanted to create a Gold Runner “engine” – a codebase that could be moved to a different platform and easily modified to get the game running on that platform. Or, the code could be easily enhanced to make a new version of the game for the MM/1.

Eventually, this “Gold Runner Engine” was shelved without ever having powered another fully completed game.

Fast forward to 2008. I had recently started working as an iPhone developer, and had written a couple of simple indie iPhone apps, and I decided that I wanted to do an iPhone game. And then it hit me. I could resurrect the Gold Runner Engine, port it to the iPhone, and not only have my first iPhone game, but at the same time resurrect my favorite computer game of all time on the newest gaming platform in existence.

And I did just that. Impressively, for code that I wrote fairly early in my career, the Gold Runner Engine ported fairly easily to the iPhone and in pretty short order I had a perfectly functioning clone of Gold Runner for the TRS-80 Color Computer on the iPhone.

I polished it up, tested it, released it, and sat back to see what would come of it.

It sold a number of copies, I really don’t remember even a vague estimate of how many.

But, within a year of my releasing it, a company had bought the rights to the original Lode Runner game and began seeking out games on various platforms which they considered to be infringing on their newly acquired intellectual property. A number of games, including Gold Runner for iOS, were targeted and removed from sale.

Back in the late 90s when I was still working on the Gold Runner Engine, I had made some modifications to it for a new game I was intending to call “Gold Runner Plus”. I added in floating (roaming) gold bricks, teleporters and moving platforms. But I never quite finished those additions to make the new game.

When Gold runner for iOS was removed from sale, I decided the best thing to do would be to resurrect that almost-completed “new” code, port it over to iOS, and release a new game, one that would have play dynamics not found in Lode Runner, and thus would be immune (I thought) to claims of copyright infringement. But finding that codebase on old 3 1/2 floppies for a long-dead computer proved difficult. Indeed I still haven’t located it.

So now I have decided that the best thing to do is just release the iOS version of Gold Runner as open source.

The project can found on Github here.

I could end this entry here, but I want to use this opportunity to get something off my chest.

While Gold Runner for iOS was still on sale, there was one common criticism found in the reviews that it got. Every reviewer said the control scheme was terrible.

Now, we’re talking about a game with a main character sprite that was as small as 8 pixels by 9 pixels, moving around a tiny screen, and having to climb ladders that were 9 pixels by 9 pixels in size, and that used a touch screen for input.

There was no ideal control scheme for such a game.

Nevertheless, I offered three control methods: 1) on-screen buttons where the character only moves as you’re touching the button 2) on-screen buttons where touching a button starts the character in motion in the given direction until a different button is pushed 3) flicking the screen in a direction starts the character moving in that direction until another flick is performed or the screen is tapped.

Game screen with button controls

Horizontal game screen using "flick" control

It took some getting used to, but after playing several times, the controls – especially the flick method, were quite usable. But computer users have a tendency to give a program, be it a game or a productivity app, one chance, and if they don’t like the UI or the control scheme, they rant about it. I think it’s ridiculous, but it’s just the way things are. Nevertheless, bad wishes to those who ripped the control scheme on the App Store.

I would love to see someone come up with a better control scheme.

Ah. I feel better now.

One final thing. The original codebase was written in ‘C’ on a system that didn’t have what would be considered frameworks or even a reasonable set of APIs, by modern standards. It was shoehorned into classes to fit iOS design patterns. As such, it isn’t exactly the most sparkling set of code I’ve ever written, not to mention the fact that I wrote the original code just two years into my professional programming career, some 15 years ago. Nevertheless, it works, and shouldn’t be too difficult to understand.

All things considered, I’m pretty proud of the work I did on it, though I would never show the code off as an example of my best work.

So that’s it. I hope someone out there gets some use out of this code, and perhaps uses it to do something cool.

If you do, I’d love to hear about it.

 

Building Better iPad Tables

September 2nd, 2011

When Cocoa Touch first debuted, it only applied to tiny little handheld devices without much screen real estate to work with. As such, it made sense that the multi-column tableviews present in Mac OS X’s flavor of Cocoa were replaced in Cocoa Touch with a single column version.

But then came the iPad.

The iPad uses Cocoa Touch, but it has much more screen real estate to work with than an iPhone or iPod Touch. The iPad is fully capable of supporting a table UI that has multiple columns. And indeed the view-based architecture supports the ability to customize table cells to your heart’s content, even on an iPhone.

Nevertheless, it doesn’t seem particularly easy to approximate the UI of a data-driven desktop app on the iPad, as there doesn’t seem to be any method for more complex table layouts on the iPad.

But that’s exactly what I need in writing Giftory for iPad.

So I wrote it.

And now I’ve released it for anybody else to use.

The primary UI for Giftory on the desktop is a display of gifts, including, for each listed gift, its name, the store it was bought from, its price, the names of its giver and receiver, its hiding place, and a couple of other relevant bits of info:

Mac OS X Giftory Table View

Table View for desktop version of Giftory

This UI utilizes text fields, popup boxes, combo boxes and check boxes to achieve its functionality.

Cocoa Touch table view cells are generally only fit to embed labels to customize the cell to display several pieces of information. Some table cells have been implemented with a label to provide the name of a data field, and an editable area where the user can enter a value for the field. But editing multiple data element values always requires utilizing another screen.

None of this is suitable for editing multiple data elements for a given data object displayed on a single table row.

I created “Reusable Dynamic Table Cell Classes” to solve this problem.

These classes provide a subclass of UITableViewCell that utilizes objects built to simulate the functionality of pop up boxes, combo boxes and check boxes, as well as standard text fields and buttons. Using these classes developers can programmatically define a row UI for their tables, associate the row with a data object, such as a dictionary or managed object, and manage the data through the generated interface:

iPad table view

Customized iPad table row using Reusable Dynamic Table Cell Classes

The classes aren’t currently suitable for situations in which the row itself needs to be selected, but they are ideal for situations in which the table rows simply display various elements of a data object, and those elements are editable.

In the next post I will go into detail about the design of the data cell classes and how to use them in code.

The open source project can be found at: http://github.com/ecrichlow/iPad-Dynamic-Table-Cells

In Search Of: The Next Platform

August 5th, 2011

For many years I’ve thought that the surest route to fame and fortune in the modern world of indie software development was to get ahead of the curve and exploit a new, emerging market before it really caught fire enough to get the attention of the big boys with multi-million dollar R&D budgets. That meant predicting what the next big unheralded  platform would be.

At one time I thought that platform was going to be In-Flight Entertainment Systems, those little screens in the backs of some airplane seats that allowed you to do everything from watch movies to play games to search for restaurants in your destination city. Unfortunately, that endeavor failed to take off, no pun intended, to any significant extent.

Next I thought that games, especially casual games, would be the big thing on Linux, which was supposed to take off as a mainstream desktop OS. But then Linux never managed to get that desktop foothold. And regardless, others had started placing bets on that market much sooner than I ever thought they would anyway.

I’m ashamed to admit that the two new platforms that really DID take off, and which I was perfectly positioned to take early advantage of as a long-time Mac developer, I completely missed the early adopter boat on. When the iPhone was opened up to third party development, I thought, “so what?” I never imagined that it would become the Next Big Thing and that simple apps that you could write in a week could make a million dollars. So you would think that I would have learned my lesson in betting against Appl… Steve Jobs. Yet, when the iPad was announced, my response was, “niche product that will never amount to much.” Oops.

So now I know never to bet against Apple/Steve again. And this means that I’m now preparing for the possibility that the next big platform is on the horizon.

Rumors are again circulating that Apple is preparing to release its own line of HDTVsIF this happens and IF such a device can run third party apps like the iPod/iPhone and iPad can, then maybe this is the Next Big Thing that I’ve been waiting years for.

Guess it’s time to start figuring out what kind of television apps I can write.

 

Apple Just Killed My Best Feature

June 26th, 2011

I don’t expect anyone to shed a tear for me. It happens all the time. Apple comes out with a new version of Max OS X or iOS, and they add something that copies (and often improves) a feature previously only available through 3rd party software.

In my case, Apple isn’t copying anything, and they’re not adding anything that hurts me. Nor are they making a change to either of their OSes that impacts me.

No, Apple is discontinuing iDisk. And with that, ends Giftory’s ability to let users post a Wish List to their iDisk Public Folder and let other Giftory and GiftoryWLR (iOS) users read it from anywhere else in the world.

Hopefully something in iCloud will turn out to be a useful replacement. My fingers are crossed.

Maybe this will be the impetus for me to come up with a shared Wish List solution that will be compatible across the Mac AND Windows versions of Giftory, the iOS Giftory Wish List Reader, AND the upcoming iPad version of Giftory. Guess I’ll have to look at this as an “opportunity”. :)

If an Application is a painting, do you, as a programmer, want to paint a picture on a blank canvas, or assemble a picture from a jigsaw puzzle?

June 2nd, 2011

As the years go by in this profession, more and more I see an expectation that professional software developers will utilize any and every framework or library available to accomplish various programming tasks.

The truth is, there isn’t very much code to write that hasn’t already been written a hundred times over. Every general programming “problem” has been solved, and there’s often a generally accepted “best” method to solve any such problem.

However, if you’re in this business because you enjoy the “art” of developing software, then you probably enjoy developing your own solutions to programming problems, even if canned solutions to those problems already exist, and even if the solutions you come up with aren’t necessarily as elegant or optimized as the solutions that already exist.

In other words, lots of us like reinventing the wheel. It’s part of what we enjoy about what we do.

When we’re working on our own independent projects, this isn’t an issue. We’re free to do as we please.

But when we’re taking a paycheck from an employer or charging a client for our time, their ultimate goal is to get the desired finished product, as quickly and cheaply as possible. Our desire to spend extra time developing our own solutions to problems is usually incompatible with their goal.

But there has to be a balance.

Yes, it may be unreasonable to decide you want to write your own xml parser on your employer’s/client’s dime when so many other canned solutions already exist.

However, keeping you engaged, challenged and interested in the project and your work is also a very important factor, for both parties.

So if someone suggests that you use Framework X to make web service calls, library C to process the returned results and open source project N to display the results in a nice, pre-fabricated UI, if that’s the majority of the application’s functionality, then they’re asking you to become a puzzle assembler, a code monkey, a paint-by-numbers “resource” who likely won’t take any joy out of the work you’re doing.

Find the balance. Determine which wheels would be unreasonable for you to reinvent, which wheels you will learn the most from reinventing and which wheels you can bring something new to the table for.

Then have at it!

But most of all, don’t get trapped assembling coding jigsaw puzzles for the rest of your career, which likely won’t be very long if that’s all you’re stuck doing.

 

Fending off Attacks on Average Joe Software Developers

April 14th, 2011

It was a year ago this week that I started this little venture.

Coincidentally, just yesterday I took part in a debate that typified the whole reason I decided to start this blog in the first place.

Be it specific to Cocoa development or more generally applied to the profession of software development, there’s a segment of our profession that only respects those with the utmost of programming skill, or at least those who strive to attain such.

In no field is EVERYONE “elite”. By definition that would be impossible. There will always be those who are “average”. In fact, by definition, the MAJORITY of people in any field will be “average”. But average doesn’t mean “mediocre”, (I just looked it up to be sure.)

A lot, if not most, of the software out there in the wild was developed and is maintained and extended by “average” programmers. These programmers are perfectly capable and competent. And they should be respected, even if they aren’t always striving to be elite, to learn all of the ins and outs of the SDK/platform/language that they’re using; even if they do things in non-standard ways; even if they buck platform conventions by trying to develop software on one platform using conventions and design patterns that they brought over from another platform.

The goal, for most programmers, is to produce a finished, working application.

Users of that application couldn’t care less how it was developed, if it “just works”.

There are programmers out there, hmmm… what did I refer to them as a year ago? Oh, yeah, “Hotshot Superstar Software Engineers“… who desire to have the most pristine, optimized, streamlined code that always uses the most appropriate aspect/feature of the language/SDK in its implementation.

Good for them. More power to them. I don’t begrudge them anything.

But personally, I would MUCH rather release a program that does something unique and is adored by users, but was implemented with code that was ugly, unoptimized and inefficient, than to write the most beautiful, optimized, streamlined, efficient routine to implement a feature 20% faster than anyone else ever has, and have users go, “meh, there’s a dozen other apps out there that do the same thing.”

So while Hotshot Superstar Software Engineers continue to degrade and belittle “average” programmers, I’ll continue to stand up for them, and proudly declare myself as a member of that group.

 

More sleeping with the enemy. Next up: Android

March 12th, 2011

As it’s now all about the money, it makes sense to look into developing for the only other viable modern smartphone OS, so I got an e-book on Android development and set out to port two of my simpler iPhone apps to it.

Much like the iPhone originals, rewriting them for Android didn’t take long, and gave me a good chance to assess Android development and compare it to the experience of iPhone development.

What did I find?

Well, first off, I almost hate to say this, because I know that one gets used to what they know, and something unfamiliar can often be perceived as frustrating, poorly designed, garbage, etc…

That said… I really, really am not a fan of Eclipse, which is the IDE that the official Android development pages tout as the de-fact Android development IDE.

When the T-Mobile G1 first came out, we dabbled a bit in Android development.

It was hard to get past the fact that there was no visual layout tool for Android that was even in the same ballpark as Interface Builder for iPhone.

It’s been a couple of years. I figured that they MUST have improved the layout tool by now.

Ummm. NO.

Sorry, but it’s absolutely terrible.

On top of that, I think the Android emulator leaves a lot to be desired compared to the iPhone/iPad simulator.

But I could live with those. I actually, at times, found myself enjoying Android development.

Except for one little thing.

Almost every time I wanted to figure out how to do something with my UI, and I searched online to find the answer, most, if not all of the answers started with something to the effect of: “in the layout xml, you…”

I’m not a fan of Java’s layouts. I’m also not a fan of performing tasks in xml. Lacking a good Interface Builder equivalent, I do most of my UI creation in code. Therefore I need answers for how to accomplish things IN CODE. I’m amazed at how hard it can be to find such answers for Android.

But the real problem is, it’s not just that the answers are hard to find, sometimes they don’t exist. Android is a very nice mobile OS, with some very nice features. However, the SDK seems kind of half-baked, because a lot of the features aren’t available programmatically, or at least are unnecessarily hard to get to programmatically.

Here’s one example:

I have a button. I have two graphics files for that button. One for the up state and one for the down state.

I expect that for any SDK for any OS that I’m using, I can find a call such that I can set those up and down images in a couple of lines of code like this:

 

setImageForState (img, BUTTON_STATE_UP);

setImageForState (img, BUTTON_STATE_DOWN);

 

Done.

And sure enough, on the iPhone, we have:

 

[button setImage:upImage for State:UIControlStateNormal];

[button setImage:downImage for State:UIControlStateSelected];

 

So how do we accomplish the same thing in an Android app?

Would you believe:

 

button.setOnTouchListener(new View.OnTouchListener() {

public boolean onTouch(View v, MotionEvent event) {

if(event.getAction()==MotionEvent.ACTION_DOWN)

button.setImageResource(R.drawable.buttonpressed);

if(event.getAction()==MotionEvent.ACTION_UP)

button.setImageResource(R.drawable.buttonup);

return false;

}

});

 

No, I’m not kidding, and it took a while to find this solution, most answers just said, “in the layout xml…”

Sorry, but that’s ridiculous.

So the bottom line is, Android is a perfectly fine mobile operating system, and it may one day be a pleasure to write for if they actually develop a decent layout design tool for it and give developers simple programmatic access to all of the functionality available through layout xml.

 

Giftory for Windows Version 1.0 Post-mortem

December 6th, 2010

Now that the Windows version of Giftory sits as a Release Candidate, with its official release imminent, I want to take a few minutes to look back on the last 12 months’ development experience with Windows, C# and .net 3.5.

Right to the point: C# is a very decent programming language and .net is a very decent framework to develop with.

Entity Framework turned out to mostly be a pleasure to work with and greatly contributed to my being able to get this project done this year.

I was greatly surprised at how much less code the Windows version has needed vs. what I had to write for  the Mac version.

Years ago I inherited a Visual Basic 6 project. After working on it for a while, I thought, “this visual development stuff is nice for small projects like this PowerPoint add-in that I’m working on, but I wouldn’t want to try to use it to develop a full-fledged application.”

I was wrong.

Visual development works quite well for full-fledged applications.

For a person, like me, who hates Microsoft and everything they have to do with with such a passion, it’s surprisingly easy to give them the credit that they’re due for all of this.

But it isn’t ALL rosy in Windows Development World. There are still some great(er) things about developing on the Mac, in Cocoa.

Now, let me lay out in more detail the pros and cons I found for each.

This isn’t going to be a REAL post-mortem. Maybe I’ll do one of those later on.

The things that are better in developing on/for Mac OS X:

  • Core Data has built-in undo/redo support. Entity Framework doesn’t. I wasn’t even gonna think about trying to implement this support manually on .net, so the Windows version doesn’t “do” undo/redo.
  • Table Views: When I first started developing in Cocoa, I wasn’t a fan of Apple’s implementation of tables. “I want to put value ‘a’ in the table at position x,y. Why can’t I just do that?!?” But after getting used to the hows and whys of Cocoa table views, I’ve really come to appreciate them. It gets a little more complicated when you want to do special things, like putting popup boxes or other UI controls in a table cell, but it’s still pretty well supported. And, most importantly, binding Core Data values to table views works pretty well. Windows also has a pretty decent implementation of table views. And they certainly offer more customizability in their tables by way of many more events on their tables that can be intercepted. But greater flexibility isn’t always better. Multiple times I found myself having to experiment with which event was more appropriate to put code into for the given situation. And sometimes it seemed like, despite ALL of those events, there was something about each one that was problematic for what I was trying to do, or none of them had my objects in the needed state when they fired. Especially when it came to Entity Framework’s integration with tables, I spent a lot of time, more time than I should have had to, trying to get things to work right, mostly when it came to putting popup boxes or other UI controls in a table cell.
  • Sheets: Well-designed Mac apps just look better than well-designed Windows apps. One reason: sheets. If you’re going to have a modal dialog anyway, it looks a lot better if the “window” is attached to its parent window and just slides down out of the title bar than putting a whole new, floating, movable modal dialog window on the screen.
  • One has never needed to know much about databases to set up a Core Data model. Model your entities and their relationships, and Xcode/Core Data handles most of the setup. This may be similar to Entity Framework in Visual Studio 2010, but not so with Entity Framework in Visual Studio 2008. I don’t DO databases. I shouldn’t have to know much, if anything, about databases or how to set them up. But, to get Entity Framework working, I had to divert my development efforts for a month or so to learn about the various types of databases available on Windows, which one was best for my purposes, how to set it up, how to modify it after integrating it with Entity Framework, etc… That sucked.
  • Built-in UI controls make apps easier to develop, better looking and easier/more pleasant to use. There’s no built-in UI element in .net to denote ongoing processing in which you can’t map it to a percentage complete? Really?!? My app is contacting a server, making a request and waiting for/receiving a response. There’s no built-in UI control to let the user know this is all going on so they can sit tight without wondering whether or not anything’s happening or if the app has locked up? Would seem like a no-brainer to have in your toolbox.
  • Exceptions: try/catch blocks are ugly. Honestly, I hate seeing them in my code. I only put them in when absolutely necessary. Frankly, they should almost NEVER be absolutely necessary. It is perfectly acceptable to have a call return an error code if it fails (or populate an error object) instead of throwing an exception. Giftory for OS X doesn’t have a single try/catch block in the code. Giftory for Windows has several.
  • Packaging apps in OS X is a thing of beauty. Many (most?) apps don’t need to be anything other than a single executable file. Okay, as developers we know OS X apps are actually folders, but to users they appear to be a single file. Windows would do well to copy this. Having to have a folder – a folder that can be seen as such by users – with files that, if they accidentally move/delete them could ruin the whole app, openly available on the user’s system is just plain bad. Open the “Applications” folder on a Mac. You see a bunch of pretty application icons that you can double-click to launch. Open up the “Program Files” folder on a Windows box. You see a bunch of folders. Ugly. Just. Plain. Ugly.
  • Core Data was introduced in OS X version 10.4. If I want to use Core Data, all I have to know is that the user is running OS X 10.4 or later. Apple does a wonderful job of integrating technologies into the operating system and making it easy for developers to utilize technologies with a minimum amount of effort. Microsoft could learn a HUGE lesson from this. I just spent the last week+ trying to figure out how to deploy an app to end users that is written in .net 3.5, uses Entity Framework, and uses SQL Server Compact Edition. Thankfully, LOTS of other developers have had the same problems I did, so there were always answers to my various questions available online. Unfortunately, often the “answers” were more like suggestions for things that worked for one person but not for another. Nevertheless, utilizing and deploying technologies that are provided by the OS vendor should not be this difficult.

The things that are better in developing on/for Windows:

  • Sometimes when developing for OS X, you want to know when a certain “event” happens so that you can base an action off of it. You then search the documentation to see if said “event” calls a method in a delegate, or triggers a notification. Often it does, but sometimes it doesn’t. In .net, however, you can almost guarantee that your event is already defined in the framework and you can write code against it. Often, there’s two or three similar events that you can use to accomplish the same task. Yes, that may seem to contradict something I said earlier, and it can be unnecessary to have too many events, but it’s still better to have too many than to have an occasion where you need an event but it isn’t there.
  • Data passing between objects: Cocoa has something called an application delegate that I use as sort of a repository for global variables, values that might be needed by disparate parts of my application. I didn’t find that .net had a similar methodology, but, surprisingly, I found that I didn’t need it. Data passing between objects somehow seemed to be either much easier, or mostly unnecessary. I’m still not sure how that worked out, but it did.
  • Creating custom views/controls is a much more pleasant experience in .net than in Cocoa. That’s possibly due to the integration of the form designer into the code editor, something which the next release of Xcode will also have, but it doesn’t yet. So, in .net, no dealing with xib files and no init’ing new controller objects with those xibs.
  • Even though I think Cocoa’s usage of sheets is much better than .net’s usage of dialogs, creating and using dialogs in .net is much easier than creating and using sheets or child windows in Cocoa. The integration of parent windows with their child windows is fantastic.
  • Customizability: This should come as no surprise. Apple is known for “forcing” adherence to their way of doing things. Microsoft is known for giving huge amounts of flexibility in the way things can be done. .net offers a lot more ways to do things the way you want them or to make controls work the way you want them to.
  • I don’t know much about databases, and I don’t want to have to. But I do know a little, and that little bit of knowledge went a long way in dealing with Entity Framework. Querying in Entity Framework turned out to be quite a bit easier than fetching results with Core Data. With Entity Framework you can write a simple query. With Core Data you have to build components that you use to construct a fetch request.
  • To this day I don’t know what most of the options for data bindings mean in the Interface Builder data bindings section. Data binding in .net, on the other hand, is much simpler. Maybe Cocoa’s implementation has more flexibility and more power, but for what I was doing I generally didn’t need it. I could bind controls to Entity Framework entities or query results with a couple of  lines of very simple code.
  • As stated above, Giftory for Windows version 1.0 has most of the same features as Giftory for Mac OS X version 3.5, yet there’s a lot less code in the .net project than there is in the Cocoa project.

I would note that I still spent my fair share of time lamenting that “I hate Windows” because of some thing or another that didn’t work the way I thought it should, whereas, in Cocoa, things usually worked the way I thought they should, even if I had to write more code to get to the finished product.

I guess this may not turn out to be my only Windows product in the long run, but I still think I can safely say that I enjoy working in Cocoa enough that a Cocoa version will always come first and always be my favorite.

Shhh!!! Don’t tell anybody!

December 5th, 2010

Giftory 3.5 is out! But nobody knows yet.

I started working on Giftory version… 4.0… I think… a year and a half ago. Didn’t quite get it done in time for Christmas 2009, so I shelved it and started working on Giftory for Windows.

As the year started winding down, I devoted some time back to the Mac version, trimmed down the new feature set, and came up with version 3.5.

Finally got that version done and tested a couple of weeks back.

Then I had to sidetrack things again to get a version built to put on Apple’s Mac App Store.

Finally, last week, I got it packaged up and put on the website.

So it’s been publicly available for a week now… but I haven’t “officially” announced it yet, because that’s waiting for the Windows version to be ready to be announced.

But if all goes well, everything will happen in the next couple of days.