The hard drive saga gets worse….

So that hard drive swap? The story got worse.

After the long weekend of swapping and getting back up to speed, I finally go back to work. Close the lid on the MacBookPro, lift it to put it into my bag… and there’s this buzzing noise coming from the hard drive. It sounded like a lightsaber (best way to describe it).

That can’t be good.

I contacted Other World Computing about it. It only makes the sound when on… doesn’t have to be going to sleep, could be lid open and in the middle of doing whatever, pick up the machine and tilt it (not even a quick tilt, just gently) and noise. So it’s not say a loose bracket or something. They opt to send me a replacement. I got the replacement just before this past weekend, and just time.

See, all the week while I had the new drive in, I had strange crashes. Some background daemon would crash, or Xcode would crash in a non-normal way (yeah, Xcode 5.0.2 crashes on me, but the crashes seem to be fairly deterministic and reliable — these new crashes were out of character).

Made worse? All day Friday while at home (the great Austin Ice Storm of 2014!) I kernel panicked 3 times. Well, more than that, but after the 3rd one I figured it was time to stop work for the day and investigate. All my crashing and panicking was coming out of processes like mds and backupd, which starts to point to disk i/o. Hrm.

So I swap in the new drive (so we have “original drive”, “replacement drive 1” and now “replacement drive 2”. I put replacement 2 in, and start the process again of restoring things. Hrm. Long story short, first restore attempts fails for some unknown reason. Try again, and it appears to have succeeded but didn’t, because reboot and while booting it panics again (couldn’t find ‘init’. That’s bad). So again I go around and around. Yeah, it starts to panic again.

And I tried tilting the machine. Sure enough, replacement 2 makes the same vibration lightsaber noise.

Well crap.

It’s unlikely to have 2 faulty drives in a row, possible, but unlikely. What gives?

I did a bunch more experimentation. After talking it over with my buddy W, it came down to a simple thing: time vs. money. To try to further diagnose this problem would require a lot of time, perhaps a week or two without the machine. I cannot afford that. If it was just for email and Facebook, whatever. But as a developer, the machine is vital to my daily existence. Time is more critical here.


I am now the proud owner of a MacBookPro11,3 — the 15″ retina model. 🙂 And the big model too, because these machines can’t really be modified or upgraded after the fact, and 16 GB of RAM and 1 TB drive space matters given what I do in a day.

No, I’m not happy to have suddenly dropped 3-grand (and yes, I got AppleCare — always do), but I’m thankful that I could.

So I’ve used Migration Assistant and things seem to be getting back to normal.

As for the other machine….

While doing some of this restore work, I had put their “replacement 1” into an external case (see their DIY upgrade kit). On a whim I tried it… I just tilted the naked drive. Sure enough, it vibrated. I’ve been in communication with OWC’s tech support, and just sent them a follow-up with a little video of the vibration noise. We’ll see what they say.

I was convinced the old MacBookPro was dying a hardware death somewhere, but now I’m not so convinced. Nothing I can do about it now… I guess it just means the kids get a nice MacBookPro for school. But we’ll see how everything shakes out in the end.

The story continues…. but I just hope that I’m nearing the end of it, at least the major headache portions.

And style keeps evolving

My coding style (programming) has evolved over time.

The biggest change I made wasn’t too long ago, when the NYTimes Style Guide came out. There were some style things in there that I had long resisted, but they made a solid case for that wasn’t just good style but also had functional implication.

One of the biggest was dealing with BOOL types.

See, while BOOL uses YES and NO as the logical constants, there’s nothing that says it must work out that way because BOOL isn’t as deeply ingrained in the Objective-C language as say bool is in the C++ language. You can read the NYTimes guide for the reasoning and style, and it’s a solid reason. I actually found myself getting bit by this very thing in an interesting way.

This is from memory, but it was something like:

- (BOOL)checkForSomeCondition {
  return (BOOL)foo; // where 'foo' was SomeObject*

Most of the time, things worked. But sometimes I had strange behaviors and crashes, which ultimately tracked down to this. I saw in the debugger that the foo pointer was non-nil, but yet it returned NO. I think that’s how it was going. Basically the logic wasn’t working out given the value of foo. So I changed it:

- (BOOL)checkForSomeCondition {
  return foo ? YES : NO;

and things worked. Hooray for compilers and scalar sizes, right?

But you can see how subtle things can bite you. And furthermore, it also shows that if I checked the return value of -checkForSomeCondition by seeing if it was equal to YES or NO, I may not have gotten the right behavior.

So that was a solid coding style change.

Now, the fantastic folks over at just created their own style guide. But their intention was a little different, because they were more concerned about style for their tutorials — print and web. Nevertheless, there are a few great things in their style guide that even in my 20 years of doing this, I hadn’t directly thought about.

1. I need to remember to use the CGRect functions instead of accessing the struct values directly. This is just bad habit that I need to work on breaking.

2. The “Golden Path”. I’ve never explicitly thought about this, but once you see it you’re like “duh!”. I always had mixed emotions about this, because it just depended. I never liked “littering” the top of methods with a lot of “if it’s not this, return” type of things. I tended to like a positive conditional flow. But yes, that could lead to a lot of nesting, which would be really bothersome if that led to a deep nest before you got to the meat of things, or if the method implementation was long (e.g. more than a screen, which can happen despite best efforts). This is something I’ll consider more as I code.

I like a lot of the things in Ray’s style guide, but there are things I do not like. Mostly those things I don’t like are because it creates exceptions. That is, you should do this, except in this case or that case. That creates too many rules to have to remember, and then things become easy to violate. I prefer to have a single rule, in the spirit of keeping things simple and consistent… because isn’t that a key reason for style? I do accept that exceptions can and must occur on occasion, but they should be the (ahem) exception and not the rule. Reading Ray’s guide felt like there were just too many exceptions. But again, they are writing a guide for a particular paradigm.

Overall I don’t think Ray’s stuff is bad tho. It adopts many established and common conventions and introduces some new ones.

If you have no particular style, just pick some established style and go with it. In time, you’ll see what works, what doesn’t work, and you too will evolve. You’ll find other style guides out there, and there will be gems within it, and new things to consider. That whole “take what is useful and discard the rest” Bruce Lee philosophy. 🙂

Hard Drive Swap

My main computer is a MacBook Pro (17″ late 2011 model 8,3). I know where the internal hard drive is located, and I’ve heard some sounds from it like a marble dropping.

That can’t be good.

So I set about the task of a replacement hard drive. Yes, I still have AppleCare and could get it replaced under warranty, but that generally means I have to wait until it actually fails and then I’m probably out my computer for a week, which I just won’t do. And that’s just to replace the drive, not even to restore my data. I’ve done this sort of thing before, and it’s not difficult, just time consuming.

But this is a little different and I wasn’t sure how to proceed.

  • I maintain a regular backup using Time Machine to an external hard drive connected via FireWire. How could I leverage that? Sure I’ve used TM to restore individual files, and the rumor is you can use it to do a full restore of your entire system to get you going again. Never done it, just how well will it work?
  • I do have my 1 internal drive partitioned into 3 partitions. Two are backed up to TM. Will they restore?
  • What about the hidden Recovery partition? How to manage that on this new drive?
  • And will in fact life be normal again and like nothing happened, after the install?

Yeah, nerves. 🙂

At least I opted to use a 3-day weekend, just in case I needed that downtime.

Here’s how it went.

I bought a “DIY upgrade Kit” from Other World Computing. It had a 1.0TB HGST 7200 RPM platter drive along with an external enclosure. I debated getting a SSD, but I’m still a little wary of the technology. OWC does sell this “Disk Doubler” solution, which I gave serious thought to because I do not use the optical drive and having an SSD for a secondary would be interesting; the thought was put all my dev work on it because compiling is so file-intensive, but then Xcode generates so many caches on the boot volume I’m not sure what gain I’d actually see. *shrug* I passed due to uncertainty and cost.

Also, the external enclosure was a good choice. I hum-hawed on it because in the past I’ve used one but after the transfer I never use it again. But still, I’m glad I had it.

The trouble was trying to find some solid answers to questions. OWC actually has a very good guide on how to do this. However, they didn’t answer some fundamental questions, like if I had to reinstall the OS. The reason was my Recovery HD was setup for Lion (Mac OS X 10.7) but I’m using Mountain Lion (10.8) and of course needed that without going through the massive hassle. Furthermore, any sort of “migratory” approach would likely cause half-installed software and other things that may or may not work, and I just don’t need that hassle of trying to get going again.

Let me cut to the end result and let you know how things went.

  1. Install new hard drive in the MacBook. Put old hard drive into the enclosure.
  2. Ensure external FireWire Time Machine drive is hooked up, then restart the MacBook Pro holding down the ‘option’ key. That allowed me to choose precisely what volume to boot from. I am fortunate the TM backup does have a Recovery HD partition on it, and before you try this route you should ensure yours has one (simple enough: hook up the machine, boot with the ‘option’ key down and see).
  3. When started from the TM’s Recovery, use Disk Utility to erase, partition, and format the new internal hard drive. I formatted as HFS+ journaled. While I will want encryption, I didn’t do that at this point.
  4. While still in TM’s Recovery, reinstall the OS. Yes, this will put Lion on the machine, but we won’t care nor use it. The main reason we need to do the OS reinstall is because this is how we get the Recovery HD installed on the internal drive. This is a must, because 1. you’ll eventually need Recovery, 2. you can’t have encrypted (FileVault) partitions without it it seems.
  5. After the OS finishes installing, it’s OK to go ahead and finish out the install process and get logged into the default account. Again, don’t bother setting up much or configuring. Certainly do NOT have the install process migrate or copy any data. You are going to throw all of this out, so just let it go.
  6. When the install is done and you’re logged in, restart the machine. Hold down the ‘option’ key and again, boot from the external TM Recovery drive.
  7. Once you’re back in Recovery, Restore from Time Machine backup. This process will erase the internal drive, copying the backup. See? We’re going to lose that Lion install. 🙂  I was only given the option to pick my boot volume’s TM backup, but that’s the most important right now.
  8. Let things churn for numerous hours.
  9. When completed, you should be able to boot via your internal hard drive and proceed.
  10. When you are logged back in, things should generally look normal. But…
    1. Be sure to quickly ensure that Time Machine backups do not start and get disabled. Just in case. Make turning TM off a priority after you first log in.
    2. Some things are probably going to be broken, like my MS Office install needed to be reactivated. No big deal, but I would say at this point to NOT try recovering everything — be mindful of disk drive access. Just note what needs fixing and come back to it later.
    3. See, Spotlight is going to want to rebuild index, and that’s going to take a long time and cause a lot of disk drive read/write head movement. We’re about to do some other things too, and well, just too many things trying to hit the disk at once causing the drive head to skip all over the place? That’s just going to be slow.
  11. Before going much further with any configuration, I found it useful to shut the machine down, unplug anything plugged into it (like my TM drive), then restart with the ‘option’ key down, just to ensure I did have a recovery partition on the new hard drive. Then boot (again) normally.
  12. Turn on FileVault encryption. I use FileVault (you don’t have to). I enable it via the System Preferences for my boot volume, which then causes the machine to have to reboot. No problem, but again another reason why not to start doing too much at this point. FileVault is going to take hours to get things encrypted, so might as well get started.
    1. In Mt. Lion you can encrypt other drives/partitions by right-clicking on the drive/partition’s icon in the Finder and an ‘Encrypt…” menu item comes up. That’s so much nicer than the prior process. Thing is again, with multiple partitions this is going to cause drive head jumping, so you might want to just note to do this sequentially later. This is especially important due to the next step.
  13. Plug in the old hard drive (in the DIY enclosure). Unmount any unnecessary partitions because Spotlight will probably want to start (re)indexing them, so avoid the churn. In my case, I needed to restore my secondary partition’s drive. I used Disk Utility’s “Restore” functionality to do a block copy of the old partition to the new partition. I had actually started Encrypting the new partition before I did this, and it caused some problems because the Restore does some low-level stuff and the 2 things got in the way of each other. No real harm, just took time. Would have been better for me to first restore, then encrypt.
  14. After that, most things were working again. I let the FileVault stuff churn. I let Spotlight churn to reindex. Yes, the machine ran a little slower because everything was churning away. I ran apps, ensured the usual cast of apps I use in a day were working and behaving right. I did find a few things here and there that didn’t get (re)installed right (like my iPhone Simulator apps), so I copied them off the old drive (see? the DIY kit was useful, if only for this process).

And slowly, things seem to be coming back to normal.

The DIY kit turned out to be useful for simple copies of things that didn’t come back, the fact I seemed to need to use it in order to do a full restore of my non-boot partition. And a couple times I actually booted off that drive because I needed some “runtime” settings and config that I didn’t remember what I did, so I’d boot back into my old setup, see how things were, then boot back to the new setup to reconfigure things.

I also learned that yes, you do have to reinstall the OS. I grant for some people it might work to reinstall the OS then do something like “migration” to get you there. It might clean a lot of cruft out. But for me? That would be too problematic and time consuming. Plus I really wasn’t sure how the fact it would have started me in Lion then I needed to get to Mountain Lion… how that would have went. I would love if there was a way to ensure your Recovery HD was in sync with your major OS upgrade. I mean, when I finally go to Mavericks (10.9), recovery and reinstall could be a bitch to jump that much.

Note that when I didn’t have the Recovery HD, my machine is a recent enough model that can do “Internet boot”. There’s some peace in knowing that’s there, but what if I don’t have fast Internet access? And the fact you must have the local Recovery HD in order to use FileVault. I wasted a lot of time having to do things over again. Again, the main question that was never answered for me was how to handle the OS version differences. I figure if I migrated, it would have been a problem. But because all I used the OS reinstall for was to get the Recovery HD and other “internals” set up on the new drive, then blew away the actual OS install by doing a full restore from my Time Machine back up… well, there we go. Life goes on.

Anyways, I think I’m going again. So far, so good. The machine feels a little more responsive too. Looking at the specs of the old (looks to be a Travelstar 7K750) vs. new drive (Travelstar 7K1000): old had 16 MB cache, new has 32 MB; old uses SATA 3Gb/s, new uses SATA 6GB/s; new seems to have just a hair faster seek and r/w times too; new tho seems to consume a hair more power tho. We’ll see how it works out. 🙂

PanemQuotidianum 1.0 is now available

December 13, 2013 (Austin, Texas) – Hsoi Enterprises LLC announces the release of PanemQuotidianum 1.0 – an iOS (iPhone/iPad) app bringing you Daily Bread for your Daily Life.

PanemQuotidianum is “daily bread” for your Catholic life.

Every day you can wake up (or go to sleep) with a bite of spiritual bread to nourish your soul. It’s light and simple, but filling and satisfying.

Simply set when you’d like to receive your panem, and you’re done. Each day at your set time, a notification will post. Respond to that notification to view that day’s posting.

PanemQuotidianum represents a labor of love, and the first collaborative effort to grow Hsoi Enterprises LLC as family business. Thank you for supporting our efforts.

PanemQuotidianum is available now in the Apple App Store for $1.99. A portion of the proceeds will be donated to Catholic charities.

PanemQuotidianum – Your Daily Bread for your Daily Life.™

kwikkEmail 1.0.3 live in the App Store

I occupy my time with writing and releasing software. The latest — kwikkEmail 1.0.3 — just went live in the App Store.

Thank you for your support.

More stuff for learning to program

A few days ago I wrote about Scratch, a nifty way to help my kids learn how to program.

I forgot a couple other things I found.

Stencyl. This looks neat. It I haven’t used it, but from what I read it looks like it follows the same sort of drag and drop “block” programming structure and logic that Scratch does. But it can be used to actually make iOS and Android products that you can actually ship and sell. So maybe after Scratch, this would be something to try. It would take the knowledge they had before, but now they have to actually make something polished and ship. A good “bridge” between the two worlds, so to speak.

There’s also GameSalad, which is made right here in Austin.

I still would want them to learn “real” languages (e.g. Objective-C, C++, Python, Ruby, Java, JavaScript, and maybe even new funky languages like Scala). Who knows. I think tho it needs to start with a desire to do it, and to really gain a love for it. If things like Scratch or Stencyl take off for them, then we’ll go there.

Who knows. 🙂


Learning to program

Youngest walks up to me about a month ago and asks how you program (write software for computers).

Oh joy! 🙂

Now I’ve talked about learning to program before and even a second time. I always come back to Karel the Robot as a great way to learn how to program. Why? Because you get to learn the constructs of programming without being burden by the constructs of programming. You can learn about loops and conditionals and variables and logic and flow, but you don’t have to spend 3 hours debugging a problem to find out it was because you misplaced a comma. And it doesn’t matter if you really do anything useful or not at this stage, in terms of gaining some employable skill (no job listings for Karel knowledge); once you learn how to program, then languages are just languages and toolsets are just toolsets.

Back when I looked at the LEGO Heavy Weapons book, No Starch Press offered other books to me to review. I asked about the Python for Kids book because it looked like it might be a great way to start the kids into programming. They sent me a copy, but I have yet to go through it. Mostly inertia on my part. Daughter asked me about it, but just a passing interest. And I must admit, while I think the book is well done for what it is, I still think it’s not a perfect start because there’s issues of language that get in the way. You have to get bogged down by syntax of Python. It’s not horrible of course, but I know things can be simpler. I think this book would make a good “phase 2”.

When Youngest asked me again, I went looking around. I found Scratch from MIT.

I think I’ve found what I’ve been looking for.

Youngest and I played around with this for a bit, doing the tutorial. I saw how Scratch gave you all the language, all the logic, even some advanced things like variables, lists, and inter-object messaging. It’s actually pretty cool. I liked the way you just drag and drop to make logic go. It also is able to give you direct feedback, which I think is good for capturing a child’s interest in the topic. I encouraged Youngest to “just try it”. What would happen if? Just try it and see! The environment is very forgiving, but even still, you can make mistakes and have to learn to debug.

I also really dig that all Scratch projects are “open source”. You can look at what others have done, and then you can look at the “source code” to see how they did it. I was able to find a simple game on the site, then show everyone how they made it happen and how neat that was.

So I’m working on this with Youngest. I told him a simple project he could start with would be reinventing comics. We all love Pearls Before Swine and I told him he could start by taking a simple Pearls comic (maybe just Pig and Rat talking to each other) and recreating it in Scratch. It’s a simple project, simple goals, but challenging enough to get your feet wet with.

And we joke… with Youngest programming… Daughter creating artwork and music… Oldest creating artwork, music, and overall design work… they all like to make movies, do voice work. Oh geez… I’ve got an in-house dev shop now!

Man, I wonder how far this ball will roll. 🙂

PracticeDeck 1.1.2 released

One of my iPhone apps, DR Performance Practice Deck for iOS version 1.1.2, is now available in the App Store.

Just a minor bug fix update, but an update nonetheless.

Thank you for your support.

My evolution of style

I don’t write about programming as much as I do other topics, but if you look at number of hours spent on something in a day, programming comes out at the top of my list. My day job has me writing iPhone apps, and my night job does too.

One topic that is a source of endless discussion amongst programmers is that of programming style. Just like you can have MLA style, the AP Stylebook, and the like, so too do programmers have a style to their writing. What we have to realize is once the code is written, it will forever be maintained — which requires reading it. Thus, style is important to aid readability, and no one questions that.

But everyone wants to question what the style should be.

And of course, my way is the right way.


I’ve been doing this long enough (I’m not a graybeard just because my beard is turning gray) to know there is no One True Way®. As long as you have some sort of consistent style and you produce readable code that’s appropriate for the context (because yes, certain programming languages and toolsets will bring about different styles), that’s essentially what matters. Yet, we still have people persisting their style is the one way that all code that a project involves must be written that way. Why? To what meaningful end does this address?

Style guides that merely propose cosmetic changes are useless and ego-driven, IMHO. But when the style has purpose and actually works to improve the code itself, has solid reasons behind the choices? That’s different.

When I started out, I didn’t have style. No one does. You eventually pick it up as you write more code. My first formal endeavor was working as a developer of a then-popular C++ Mac framework called PowerPlant. When I asked about coding style, the Grew Dow (creator) said “mine”. 🙂  Basically, PowerPlant was Greg’s baby and if I was going to write code for it to be included in the official distribution of it, I had to make my code look like his. This was a lot more than just where the curly braces went, but a lot of other form and function choices too. IIRC, Greg taught me this:

bool x = false;
if (SomeTest()) {
    x = true;
return x;

Compare to this:

bool x;
if (SomeTest()) {
    x = true;
else {
    x = false;
return x;

The first is more readable, more compact code, and generates better code too. The end result is the same. Go with the first.

This was a matter of style, but it produced better code.


Over the years my style has changed. In fact, one change happened within the past year, and I’m pretty happy with it. It concerns everyone’s favorite debate: curly braces!

I started out with:

if (foo)

Because whitespace is good. Thus why I didn’t like:

if (foo) {
} else {

Because while compact and nice on screen space, it wasn’t as good on the eye because the “else” wasn’t in a column with the “if” (for visual scanning, since we sometimes will process the code in “blurry” visual chunks, not necessarily processing the actual code), and depending upon the complexity of the code, readability wasn’t always best.

I flipped flopped around for a while on this, especially since Cocoa coding brings a lot of its own conventions to the mix, which for the most part are well-worth adopting especially since some are imposed on you in order to make things work. My current style?

if (foo) {
else {

I find this works better because there’s better visual chunking of the data, better organization. It helps to keep the code compact, doesn’t waste too much space, but yet still keeps some whitespace around. It’s hard to get a feel for this style in small code snippets, but when you use it all day in various bits of code, it gets vetted and I’ve found this works quite well.

Of course, do-while is still potentially weird. 🙂


I still debate this one.

I think it’s clearer to say:

NSString* string;


NSString *string;

Because to me, it’s making the type clear. That is, this is an NSString pointer. It makes sense too when you look at function/method arguments, be it C, C++, or Objective-C, because you declare return types as such and arguments do not always need a variable name, just the type. Thus:

- (NSString*)foo:(NSString*)s;

is legit and correct.

The only place I find this breaks down is if you wish to declare variables with a comma:

NSString* string1, *string2;

So you have to do that. But I also think it’s generally bad-form to declare with a comma, especially since it gets really messy looking with initialization, and in general you should initialize your variables (at declaration time).


Another style change I made was spaces. Or rather, spaces vs. tabs.

I always used tabs. I preferred tabs. It made editing a lot easier. I did set my tabs to 4 spaces, but I still used tabs. I hated people that used spaces instead of tabs because it made editing hard.

When I came to my current day job, the server side was being done with Ruby (and Ruby on Rails). Those guys like spaces, and using 2 spaces per tab. And so, the clash began. The then-lead on things asked us to just switch to using spaces instead of tabs (tho we could stay at 4 per), and I just gave in because it was easier. Because that really was the problem: mixed setups.

I recall back at Metrowerks, most people used tabs with 4 spaces per tabs. I think one guy liked 8 spaces per tab, and then there was another guy that liked 3. Yes… 3. That made his code really weird to look at when you opened it up in your editor, because things lined up really wonky. And so problems arose when you couldn’t really read someone’s code (back to that readability thing), and it was made worse when people with different tab settings edited the same file.

Basically, it became a huge mess once you left the ability to have a homogeneous environment and complete control over it.

Using spaces instead of tabs fixes most of that. You can’t fix if people use different substitution values (e.g. 2 per vs. 4 per), but you will still end up with consistent-looking code when you open it up in a different editor, because a space is a space.

But this made me realize why I resisted for so long.


Your choice of editor tool matters, and affects your style.

For example, with the spaces vs. tabs situation, I hated using spaces because if I hit tab too many times, now I have to backspace a LOT in order to delete all those spaces, instead of just a couple backspaces to undo what I did. Typing out code isn’t like typing out a letter or a blog post, because a lot of keystrokes can be for formatting and navigation around the code. So now to have to do all this extra work, it adds up in a day.

But now, I have an editor that is smart(er) about this situation. So if I have tabs actually be 4 spaces, I hit tab, the cursor “tabs in” but really 4 spaces were entered. And if I mess up and press delete, it will “untab” and delete the 4 spaces. Having an editor that is smart about such things really goes a long way, not just towards helping you write code, but helping you manage these sorts of style choices.

I would also add that the growth of screen size and resolution has helped a great deal. We aren’t using VT100 terminals limited to 24 rows and 80 columns, yet some people still cling to that standard. Why? Even our tiny mobile devices aren’t so limited. Granted, if you are in a particular environment that requires such constraints that’s one thing. But I primarily work on a 17″ MacBook Pro with a 1920×1200 screen; I used to work with 2-3 total monitors. We have the space, we should use it. Our eyes like to see a wide horizontal plane (thus why TV’s are widescreen and movies are wider not taller). Use that.

Thankfully Xcode is really getting better about these things. It’s taken a while, and it was really important for Xcode to be an awesome editor because the 3rd party editor road and integration/support was just not happening.

One thing that I’ve also given into is code completion. I didn’t like it because hey… what’s so hard about typing things out? Well, with some iOS/Cocoa API’s, it’s quite hard because the names can be VERY long and difficult to remember. So code completion has worked out to be a quite useful thing. But with that comes some imposition of style because someone had to decide how to insert that text. Xcode also allows some level of syntax-aware editing, where it can do things like auto-indent and the like. You have some control to pick and choose, and really once you tweak things to your liking the automation is nice. But again, there’s some level of imposition of style here that you cannot get around, especially if your choice isn’t represented in Xcode’s options.

Point is, your choice of editor can be a bane and a boon. In general, they should be there to help you write better code, more efficiently. But while doing so, it may require you to make some choices in your coding style. Don’t fight it, go with it. You might find some benefit to that stylistic approach. It’s worth the time to experiment with it, especially if it winds up improving your point of view, improving your code, or just giving you solid reasons and experience behind your rejection of that approach.

Editor Customization

And so, if the editor app matters, hopefully you can customize it to suit your needs.

I can touch-type, and I find it much faster to use keystrokes than to stop and utilize the mouse – I don’t have to (re)move (then replace) my hands. I know many people that use laptops as their primary computer, but hook up external keyboards and mice to it. To an extent I understand this, but again it’s about having good tools. If you use the keypad a fair deal, the loss of it on a laptop keyboard is a detriment. If your laptop’s pointing device merely moves the cursor on screen, an external mouse may work better for you (especially that scrollwheel). But I’m happy my MacBook Pro’s trackpad supports gestures, and I use them constantly to allow me to more easily move about not just my source code, but my whole computer. Taking advantage of Spaces (well, Mission Control – having multiple Desktops) is a big boon because I can put my communication (email, web, IM/chat) on one Desktop, Xcode on another, etc.. Gestures are useful.

Granted, I cannot customize the gestures so much as I can customize keyboard keystrokes. But thankfully I can and use that to help me efficient access the commands I use most.

Another customization has been the use of editor color. I like the solarized project for how it effectively syntax colors, but also is very easy on the eyes. Quite important when you’re staring at the screen all day.

Plugins are useful too, and this comes more directly back to my discussion of style. I found a useful plugin, VVDocumenter-Xcode. This is a simple Xcode plugin that with a simple keystroke inserts basic formatting for appledoc-style documentation (and I’m going to modify this for Xcode 5). Just like the endless debate about comments in code, there’s debate about how much documentation one should have. I am not always good about complete documentation (you get into a groove with coding, documentation becomes a secondary concern, then you don’t have time to go back), but a plugin like this makes it much easier. Furthermore, with some advances in Xcode 5, there’s even more incentive to document in a particular structure. I cannot comment further yet as Xcode 5 is presently under NDA. Nevertheless, documentation and documentation style is an important consideration in your coding practice. Because again, style is about making readable and maintainable code.

The Style of No-Style

Styles tend to not only separate men – because they have their own doctrines and then the doctrine became the gospel truth that you cannot change. But if you do not have a style, if you just say: Well, here I am as a human being, how can I express myself totally and completely? Now, that way you won’t create a style, because style is a crystallization. That way, it’s a process of continuing growth.

– Bruce Lee

My style is my style. It is what allows me to most effectively communicate. It is what allows me to best express my thoughts, in code, in implementing a solution to a problem. For me to use your style would get in the way of my effective communication, so why should I do it?

I look at modern programming teams. Typically they are comprised of many people of different backgrounds, and often these days, ethnicities and origins. I say this because not everyone on the team might speak English the same as you or as well as you. Joe speaks with a southern accent and phrasing, and Young-soo speaks more in Engrish. If we forced “1 true way” of speaking upon Joe and Young-soo, if we made them all speak in British English (colloquialisms and all), how effective would that be for the team? We’d never think of doing such a thing, yet it’s precisely what we do when we impose “1 true style” of coding upon a whole team. Does that really lend to effective coding? to effective communication and expression?

Or can we accept that there’s at least enough of a style, enough of a standard in place that allows us to get the job done with each member expressing themselves as best as they can? Oh sure, if we find ways to help improve our communication, we should improve (e.g. allow your style to evolve). Just keep in mind what a coding style is to be for, and work towards enabling the team to effectively express themselves and write successful code.

If you have no particular style, if you need to find some way to improve the team’s workings, adopting style guides such as the NYTimes Objective-C Style Guide can be useful. Even if you don’t need such a guide, consider what the guide has because there may be a new twist or technique that allows you to improve your code. For example, reading that guide reminded me about Xcode’s expanded support for literals and how BOOL isn’t quite what you think. If we can write better code, if we can more fully express ourselves, style is a benefit. Just keep it in such perspective.

Circular Piracy

Game developer, Greenheart Games, created a game about creating games called Game Dev Tycoon. It’s a familiar game genre, a sort of “Sims” about being a software game developer. I haven’t played it, but it seems cool.

But what I thought was really cool? What they did to make a point about piracy:

In a curious social experiment, the developer deliberately uploaded a full, cracked version of its game to the most popular torrent trackers. The cracked version is nearly identical to the real thing except for one detail. As players spend a few hours playing and growing their own game dev company, they will start to see the following message, styled like any other in-game message:

“Boss, it seems that while many players play our new game, they steal it by downloading a cracked version rather than buying it legally. If players don’t buy the games they like, we will sooner or later go bankrupt.”

Slowly, the player’s in-game funds will dwindle, and every new game that they create has a high chance to be pirated until they eventually go bankrupt. There is no way to fight it, in an ironic twist, players of the cracked version of the game are doomed to constant failure due to rampant piracy.

I thought that was pretty clever. It’s an old argument and issue for sure, but I like that because they granted the realities of the game they were making and that they were making a game, they had an avenue to make a point and they chose to make that point. So why make that point?  From their own website:

Game Dev Tycoon was created by two brothers. They invested all their savings to start a company and develop the game. They truly enjoy tycoon and simulation games and after seeing many of the new social and pay-to-play games where buying coins is more important than good gameplay, they wanted to bring some true simulation games back. Their motto is less social, less ville, more game and they believed that there is a market for real simulation games but as independent game developers it’s difficult to survive and the reason why so many companies create pay-to-play or coin-driven games are because they make more money with them.

If you like the look of Game Dev Tycoon and you want to see more games like these then you should really think about buying a legal copy of the game. The price of the game is reasonable (7.99USD), you get legal copies for Mac, Windows and Linux, free service updates and you can even install the game on a couple of your personal computers.

If you don’t care about all of this and just want to get a cracked and illegal version then we can’t do anything about that, but if years down the track you wonder why there are no games like these anymore and all you get to play is pay-to-play and social games designed to suck money out of your pockets then the reason will stare back at you in the mirror.

I’ve been writing software for 20-some years. I complete understand. I mean, I dealt with piracy before Napster and torrents. I do sympathize with any artist and person that wishes to make their living on “digital data”, be it software, music, movies, books, whatever — something that’s easy to copy and distribute. I sympathize because that’s how I earn my living and feed my family! I don’t sympathize with the way “Big Media” has gone about trying to enforce things because I learned long ago that pirates will always pirate and good people eventually will pay up, so long as they understand and are given reasonable terms. Since I have limited resources (time, money, energy), I can either work to make my product better or fight the people that I’ll never win over anyways; so why not please those willing to be my customers? Draconian DRM that hampers and just pisses off your legit customers isn’t the right way to go (witness: SimCity 2013’s rollout).

What it really takes to improve this situation is for the public to be educated.

The Klug brothers are right: if you want good things, you have to support those willing to make good things. If you like games like this, support them so they can keep making these things that you like. It’s pretty simple. It doesn’t matter if it’s your favorite music artist, movie studio, game developer, book author… whomever and whatever. These people have worked hard to produce something, something that you now enjoy and has made your life better. Is it fair for you to take and not give anything in return? Would you appreciate someone doing this with the fruits of your labor? Is the way we should get people to pay by forcing them with ugly DRM and shitty experiences (think about this next time you try to play a Blu-Ray and are forced to sit through FBI Warnings)? is that high quality? is that how you want things to be in life? Or would you rather be willing participant in the process and support those that make your life better?

Which way do you want it?