License to Code

As a software engineer I don’t often find myself in scary or life threatening situations – at least not as a direct consequence of my career choice.

Not too long ago, however, I was working on a customer project in which some core functions were lifted from a previous version of the same product. I was told to just re-use what was already there – no point in re-inventing the wheel, right?

As it turned out, the old code was not really doing what it should. This was not a revelation per-se, pretty much all code has some bug or another if you dig deep enough, but the one I found was sufficiently odd to cause me to dig a bit deeper.

Eventually it led me to this (names has been changed to protect the innocent):

private void calc(int x, int y, String sl, String l)
{
  ArrayList<Obj> list = new ArrayList<Obj>();
  list.add(new Obj(14.29,70,0));
  list.add(new Obj(10.53,95,0));
  list.add(new Obj(8.33,120,0));
  list.add(new Obj(6.90,145,0));
  list.add(new Obj(11.11,70,20));
  list.add(new Obj(8.70,95,20));
  list.add(new Obj(7.14,120,20));
  list.add(new Obj(6.06,145,20));
  list.add(new Obj(10.00,70,30));
  list.add(new Obj(8.00,95,30));
  list.add(new Obj(6.67,120,30));
  list.add(new Obj(5.71,145,30));
  list.add(new Obj(9.09,70,40));
  list.add(new Obj(7.41,95,40));
  list.add(new Obj(6.25,120,40));
  list.add(new Obj(5.41,145,40));
  list.add(new Obj(8.33,70,50));
  list.add(new Obj(6.90,95,50));
  list.add(new Obj(5.88,120,50));
  list.add(new Obj(5.13,145,50));
  list.add(new Obj(7.69,70,60));
  list.add(new Obj(6.45,95,60));
  list.add(new Obj(5.56,120,60));
  list.add(new Obj(4.88,145,60));

  for(Obj obj : list)
  {
    if(obj.getX() == x && obj.getY() == y)
    {
      Double answer = 
        obj.getValue() * Double.parseDouble(sl) * Double.parseDouble(l);
      someFunction(answer);
    }
  }
}

I did not include the source for Obj because it doesn’t really matter, so I’ll spare you the time to review what this does and just spell it out for you:

answer = sl*l*(1000/(x+y))

If someone had presented me with this out of context, I would have assumed it was a joke, but it’s not. It’s actual production code from a real-world application, and it’s just wrong on so many levels that I’m not even going to bother dissecting it.

Instead, I’d like to return to the part about my job not being scary or life threatening.

In this case the application was benign and, although stupid, the code did (almost) what it should (round-off errors aside), but seeing this piece of code, and realising that there are actually people out there who call them selves “programmers” or “engineers” who’d do something like that, it occurred to me how ridiculously dangerous bad programmers are.

It’s not just about wasting time, or being annoying, but who is to say that this person won’t end up working for the bank that looks after my money? Or some company that writes control code for nuclear submarines?

Considering that I’m hardly allowed to install a lightbulb in my own home without a license, it’s downright scary that people are allowed to work on software when they have no clue, let alone a license.

2016 MacBook PRO review

Update 2017/3/14:

I’ve been meaning to append an update to this post for a while, but have been too busy to do so. Today, I was once again reminded about it for reasons I’ll get back to shortly.

So, immediately after the original blog post, I had two major issues:

  1. It had a HW glitch in the keyboard (Hubris for being too tough on Dell, I’m sure) – basically the ‘O’ key only worked one of three times it was pressed. Apple replaced it overnight, no prob.
  2. Then I was consistently getting a black screen on start up if I had entered sleep mode with my external monitor attached. Apple tried for a short while to blame my external monitor… That stopped when they learned that it’s an Apple Thunderbolt display. There was another feeble attempt at blaming 3rd party software, so I reset the machine to factory and the problem didn’t go away. So, finally convinced, they offered to take it back, but I would then have to wait 3 months for a new one because it’s a custom build. I finally opted to just have it repaired. One more night in the shop, and everything has been fine since. So, early build, monday model, lemon, I don’t know, but I guess no matter what you pay, you can never be sure HW won’t have issues. Lesson learned.

In both cases Apple Support has been top notch (safe the external monitor thing, but that was actually kind of funny 🙂 ). When things do go bad, and they do, good customer support is all I really ask for, and Apple’s is second to none. I leave them my number, 30 seconds later they call back and walk me through the various tests and problems until there’s a solution.

HW glitches aside, there’s a couple of things that I wrote about originally that I now have a 3+ months perspective on:

Weight and size does matter. I was unsure if the modest reduction would make any difference, but it is noticeably nimbler on an every day basis. It also is way more silent than the old one and it does not have the same hotspots around the charging port, for example.

Performance, well, it’s the same story every time you upgrade. It only takes a few days to get used to it, and you then forget what it was like before. Only thing I’ve noticed consistently is that I have much less graphics issues in Unity. Before, I would get weird texture glitches every now and then (lack of GPU memory probably), and had to restart Unity. I haven’t seen that since I got the new laptop.

The USB-C port, much as I predicted, has been a non-issue. Or rather, it has turned out to be more annoying for others because they can’t borrow my charger or my lightning cable, but since that greatly reduces my risk of loosing either, I consider it an overall win 🙂

The O-led display however… Well, it’s the reason I finally decided to write this, because it’s such a ridiculous non-feature that I just had to vent. It has no practical purpose what so ever; it does nothing that I couldn’t do without it. Nothing. But if it was just that, if it was just a party trick, I could try to forget how much it probably added to the BOM and simply ignore it. But that’s exactly the problem, it’s not just useless. It is in fact incredibly annoying on a daily basis.

The bar have no tactile feedback, so even just using it as if it was a row of regular old function keys is a step down compared to a normal keyboard. But it gets worse because of how good the touch is. I usually hover my finger over the F7 and F8 keys when debugging, but now I can’t because it causes random taps when I don’t want them. And don’t get me started on how many times I’ve been asked if I want to turn Siri on. I do not plan to talk to my laptop. Ever. So you can stop asking, but the damn button is right above the backspace key, so if your finger is just a wee bit off, Siri will think you called. Same story in the other side where F1 is so easily activated that I get annoying help dialogs all over the place.

Apple, seriously, what were you thinking? Did this “feature” go straight from Ive’s skull directly into production – nobody actually tested it?

If you absolutely had to change the keyboard, how about you fix the goddamn cursor keys. Yes, I would like full size up/down keys also – I’m a grown up, I have grown-up-size fingers.

Yes, I could use an external keyboard, but at this price, I really shouldn’t have to.

Original post follows below:

Me and my laptop

It’s been 4 years since I bought my trusty MacBook PRO retina. That’s easily a year more than I’ve ever had a laptop before, and the first time ever that I was in doubt as to whether it made sense to get a new one.

All the laptops I’ve had before (Top of the line Dells and Lenovos, typically) has started getting tired after less than 2 years, making the last year of ownership a real drag. Part of that has been due to Windows bloat and build up of crud in the registry and file system in general, so in part I suspect the MacBook has lived longer not just because of its hardware but also because of OsX, but the hardware is certainly part of it.

(On a side note, the Dells have been notorious for needing hardware replacements; from keyboards loosing keys to graphics cards getting bugged colours or weird artefacts, I’ve made extensive use of the next-business-day service. In fact, my wife got a Dell not too long ago and had to replace the HDD after just a few weeks – They might be ok for home computers, but they’re anything but a professional tool and I’ve had my last Dell for sure).

Still, 4 years in with the MacBook, and I feel like it could easily have done a year or two more, but two things were nudging me towards a new laptop – the 256GB SSD was constantly kissing the 95% mark and I had to do frequent cleanups in my temp and trash folders to be able to work (not a bad thing per-se 🙂 ) and the graphics card was sometimes struggling a bit with two large displays running Unity, photoshop and Blender at the same time, causing the fan to be on more than I would have liked.

Enter the 2016 MacBook Pro.

IMG_1954.jpg

First of all, let’s get the price of out of the way: It’s ridiculous – there is no justification for it, other than Apple charging big bucks because they know they can. For me, as for most people in my situation I would guess, it is, however, also somewhat irrelevant.

It’s my primary work horse – the only tool I own (aside from software licenses), and I buy one every 3 (now 4) years and use it 10 hours every day – saving $1000 and risk getting a Dell-esque piece-of-crap Hardware that needs a new HDD in the middle of the week, costing me a couple of days worth of work, just isn’t an option. The fact that it lasts a year or two more than the competition means I would probably pay even more if needed (Don’t tell Apple that though 😉 )

So, with that out of the way, what am I getting for all my cash?

It’s obviously lighter and thinner – I only just got it so can’t say if this is anything I’ll really notice, but since I drag it around all the time, less is definitely better. The limited testing I’ve done suggests that it also stays cooler, which was my only real concern with the reduced size. The old one could get seriously hot around the hinge when Unity was pushing polygons at 60FPS so I had a (seemingly unwarranted) suspicion that a smaller form-factor might make it harder to get rid of the heat and thus make the problem worse.

I love the keyboard. It’s a bit click-y-ti-clack where the old one was dead silent, but the feel is just phenomenal. I actually think I type faster and make less typos, though that could be a euphoria-induced illusion ;).

The touch pad is even more awesome. I loved the old one which was leaps beyond anything I’d ever had on any other laptop, yet it pales next to the new one. Everything from the sound it makes to the very subtle, yet rewardingly haptic, feedback when you press it is just best-of-class – nothing I’ve tried on any other laptop (mine or others) are in the same ballpark – hell, they are not even in the same galaxy. It’s so good that I feel a bit bad for throwing $100 at a new magic mouse 🙂

The O-led display that replaces the function keys is… Well, it’s a gimmick. A very expensive one, I presume. I really don’t see the point of it, and seriously doubt I’ll ever use it, but I’m going to try to keep an open mind. Maybe there some kind of use for it, and I just can’t see it, but this is probably the one thing I would have taken out if I could, just to save a few bucks.

USB-C… I *really* hate that I can no longer use my thunderbolt display as a charger. This, to me, is the only really annoying “feature” of the new MacBook, but I still think it was the right thing to do. My old macbook would get quite hot around the magnetic charging port, so I suspect the connection wasn’t all that fantastic, even if it was a great concept, and having a single shared port for everything just seems like the right thing to do. The world probably isn’t ready for it, but it wasn’t ready for tablets either, and that changed quick enough. Having an adapter for my other legacy peripherals is a minor moan, that I suspect will go away faster than I can possibly imagine. So thumbs up for paving the way for a world of fewer odd cables, though I wish I could have bought a mag-charger adapter.

I now have 512 GB of SSD which should keep me running for the next 4 years (my 256 GB disk has been almost full for 4 years, so it’s not like my needs are skyrocketing, but every new project I start do tend to add a handfull of GB, so it’s nice to not have to worry about it).

The new graphics card is fast. The old one was never a problem, but I can quite clearly feel the difference when working in Unity – projects that were just barely managing 60FPS in the editor are now keeping an almost constant 100FPS. I know this isn’t a cardinal point for everyone, but for me, this upgrade alone was worth the price.

It’s pretty much the same CPU I had in the old one, though the memory is faster, so I suspect that a benchmark would tell me that everything runs a tad quicker, but probably not enough to have any real-world impact on my daily use. If I consider a typical day in my life, the amount of time I spend waiting for CPU bottlenecks is probably less than the time I spend getting coffee (Yes, I drink too much coffee, but that can’t be helped). I much prefer a smaller, cooler, less battery hungry machine over one that is 15% faster in those few cases where it actually matters, so CPU was never a concern for me.

Finally, I love that I can have it in space grey 🙂

Ups and Downs of Apple TestFlight

UPDATE #4 (20151109):

Everything was fine for a while – Even the build-in “Upload to  App Store…” button in XCode worked as it should, but nothing good lasts forever. Recently I’ve been getting the “You’re not authorised to use this service” error, which is of course complete bullocks and not at all related to whatever the problem is.

I know this because using the Export function and uploading the same IPA with the same credentials with Application Loader works most of the time. The only time it doesn’t work is when XCode decides I’m not authorised and refuses to upload, but still feels a need to lock some file that Application Loader also needs access to. Brilliant…

How is this in any way a difficult problem to fix? Take this crazy idea for example: How about letting the “Upload to App Store…” button do an export and pass the file to the Application Loader.

Yeah I know, crazy idea…

UPDATE #3 (20150902):

Out of necessity I recently re-visited external testing in test flight and found that the review process has been greatly simplified with most (if not all?) of the silly requirements removed and time-to-review down to around a day or so.

Bottom line is that this post is no longer relevant – Apple has stepped up and fixed TestFlight. I could still wonder why it took so long, but I’m just happy it works 🙂

UPDATE #2 (20150604):

That’s a funny coincidence.

Last night all my pre-releases suddenly disappeared from iTunes for a couple of hours, and today – all the builds I’ve done have automatically become active without me having to hit “save” on iTunes Connect.

I’d like to think that Apple actually listens to small developers and that my little rant paid of, but chances are I’m not the only one who complained and it just happened that they fixed it a few days after I finally had enough :).

Anyway: thanks 🙂 Now for the second half of the problem …

UPDATE #1 (20150601):

As I am (once again) waiting for iTunes to update, I was thinking of this post and it occurred to me that this whole sorry mess could be fixed with just 2 simple changes:

1. Provide a way to enter the “what to test” text before uploading so I don’t have to log in to iTunes Connect.
2. Remove the ridiculous review process from the test accounts.

Come on Apple, do something good for your developers for a change?

ORIGINAL POST:

I really don’t have time for this, but seeing as I am waiting for TestFlight anyway, this seems like a good time to vent some frustration.

Last year, Apple acquired TestFlight – the awesome service that let you drop new builds in the hands of your clients in minutes with very little fuzz, once it was set up. Which was a bit of a pain (not because of TestFlight, mind you, but because of Apple).

Here is how that worked in my daily life:

  1. Build App
  2. Wait for XCode to complete
  3. TestFlight immediately discovered the new build and opened its wizard
  4. Fill in information, select team, hit publish, done. One single flow with no waiting (Uploading was done in the background)

So… Apple acquired TestFlight and you would think that they would fix the one issue with TF: the setup. Admittedly, setup is marginally simpler than before but even this they’ve manage to screw up. Really it’s just stupid in a different way, but I’ll get back to that later.

In any case, it’s not that big a deal. I go through the setup phase once for each client so I can live with a few bumps on that road. Builds, however, is a different story. Some days I do 5-10 builds for a single client while ironing out odd issues or testing various designs, so the build process is what matters to me.

Here is what that looks like today:

  1. Build
  2. Wait
  3. Open Organizer
  4. Hit Submit To AppStore
  5. Wait
  6. Pick team
  7. Hit Submit (again)
  8. Wait (a very very long time)
  9. Hit Done (Except, we’re not, are we?)
  10. Open iTunes Connect in a browser
  11. Log in
  12. Navigate to the app MyApps->App->Prerelease
  13. Keep hitting “refresh” while you:
  14. WAIT some more for the state to go from Uploaded to Processing to finally appear in the list
  15. Click the build and put in some random crap in the “what to test” field
  16. Save
  17. Hurray, it’s live

You may think I’m making this up, but trust me, this is ridiculous far beyond my imagination.

So let’s return to the registration process. Before you had a limit of 100 registered devices per developer account and you had to manually register each of them, and make sure you cleared them out yearly so you wouldn’t run out. This was annoying, but I could cope, and though I’ve been in the 60+ registered devices range, the limit was never critical.

Now you can invite testers by e-mail rather than device ID which is great. Awesome. The problem: You can have 25 of these.

Twenty-five. It’s so absurd I have no words for it. I’m a small-time developer, and I’m going to break that limit almost immediately. The only way for me to not run into problems is by telling my clients that they have to limit who can test their apps. That’s a great way to start a relationship with a client.

And the fun doesn’t stop there either. These 25 people are “internal testers” which means they must be created as iTunes Connect users with access to my developer account. Why Apple? Seriously?

Now, Apple’s “big news” when they revealed this new (broken) TestFlight was that you could now have 1000 beta testers of your app, which should have sounded too good to be true. Because it is.

In order to get your app to any of these “external” testers, it must first be reviewed and approved, which means creating icons, asset and descriptions and making sure it does not tickle Apple in any inappropriate manner. Setting all this up takes hours, time that I have to bill my clients. All for an app that is just a prototype for a very limited audience.

It’s most fascinating how a company with unlimited financial resources, massive development teams and complete control over all the involved software (and hardware) components can spend almost a year to reduce a perfectly working service to a stinking pile of pooh.

Well done…

SOAK! Released in Denmark and Sweden

Finally…

EveryplayBanner

The first public release of SOAK! is now available in the Danish and Swedish app stores – we decided to do a limited rollout so that we could get a chance to test basic features like app store and GameCenter integration in the wild, but still on a small scale. The rest of the world follows shortly and then comes the Android port.

We actually launched the game almost a month ago but immediately found a critical bug that hadn’t shown up in sandbox mode and had to pull it, so, once bitten 🙂

Please do let us know what you think – we have a huge list of things we’re going to add over the coming months, but more of that in due time, now we need to start spreading the word…

https://itunes.apple.com/dk/app/soak/id876006257?l=sv&ls=1&mt=8

XCode6 and the mystery of the missing rect

Since “upgrading” to XCode6 I’ve had issues with storyboard based UI’s that used to work, but now suddenly starts acting really weird – table cells that scale to double size of the containing table, and buttons that don’t react to input because their parent (non clipping) views are cut in half.

Everything looks fine and dandy in XCode, but breaks horribly when running the app on both iOS7 and 8 and both on real devices and in the simulator.

In two cases I tracked the problem down to missing or incorrectly updated view rects – if you open the storyboard in a text editor (or rename it to .xml and open it in XCode or, even better, AppCode) and locate the view that’s causing problems, there’s a good chance you’ll see a rect with incorrect dimensions or simply won’t see any rects at all.

The structure should be:

...
 <view key="view" contentMode="scaleToFill" id="xMb-eO-e2t">
 <rect key="frame" x="0.0" y="0.0" width="320" height="504"/>
 <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
 <subviews>
...

I.e. a <rect> before the <autoresizemask>.

Correcting or inserting the rect fixes the problems and should be ok as long as you don’t do something silly like, say, edit the storyboard in XCode6’s storyboard editor.

But it’s ok. I understand that Apple, with its limited resources, can’t fix every single little insignificant corner-case in XCode when they need to focus their energy on inventing important new and productive programming languages. //sarcasm…

May I just humbly suggest that they got their priorities ass-backwards?

#MadeWithUnity in 7 days

7 Days

IMG_06727 days after I got up in the middle of the night and – for no particular reason – decided to add my own peculiar contribution to a very long list of color-match puzzle games for mobile devices, I finished and uploaded the release build of Qube Crush 3D.

That’s 7 days (and nights) from initial spark to a completed F2P game with 50 levels of brain bending puzzles uploaded to the App Store.

Just to prove to myself that it wasn’t a fluke or a happy accident, and since I had a week or two to burn while waiting for the AppStore review process to complete, I decided to do another game in the mean time.

This was to be a 2 player arena battle game and the result is Magic Micro Battle Arena, which I completed in just 5 days – mostly because it has no IAPs or Ads and no highscores, so less integration work and no horrible IAP testing. Ironically, it also got approved faster because Qube Crush got rejected due to an issue with my AdColony integration.

IMG_0611So two fully functional playable games completed in two weeks. These are not Gears of War or Doom 8, and their feature lists has been cut to the bones, but anyone with an idea of just how much time the crud of project setup, tool chain woes, app-store nightmares and 3rd party integration (not to mention play-testing) usually takes, should realize what an amazingly short time-to-market that is.

The rapid development probably means I missed a bug here or there, and I could certainly have polished both of these two games for another couple of weeks, or months even, but before I do, I’d like to know that there is at least someone out there who wants to play it ;).

Because my investment is so limited, I can try whatever crazy ideas I come up with, and if it fails, I can move on without bleeding to death.

Unity Rocks!

And that’s really why I’m writing this blog post. Because of how this is all possible. Obviously, I *am* a pretty awesome developer (hah! 🙂 ) but, truth be told, I owe most of my productivity to the game-dev tools we have at our disposal today, and at the heart of those is (in my case at least) Unity3d.

I can’t say enough good things about Unity – sure, it has its bugs and quirks and annoying issues, but at the end of the day it’s just so insanely productive that I hardly notice.

I run a 4-screen setup with Unity and Blender on a big cinema display, photoshop on my Cintiq and Mono on my laptop with either my phone or iPad hooked up for testing – with Unity’s rapid automatic import there is no sense of context switching, it’s as if it’s one big application build up of state-of-the-art parts (minus Mono which is anything but).

IMG_0674Testing and trying out stuff in Unity is so quick and easy that in two weeks, I have not once had to start the debugger. Mind you, if launching the debugger from Mono wasn’t such a nightmare, I’d probably been able to finish the games even without cancelling my weekends 🙂

So here’s to the guys at Unity: YOU ROCK!

(But please find a replacement for Mono. For those of us who’d rather chop off our left arm than install Windows, Mono is still (if only barely) the preferable option, but I’d really like to see a Unity/JetBrains C# IDE with bullet proof indexing, a nice coder friendly editor and proper refactoring that does not break script-to-game-object bindings).

If you have an iOS device you can get the apps on the AppStore – Qube Crush is free* and Micro Arena is $1 (if you ask nicely I may have a promo-code for you 🙂 )

https://itunes.apple.com/us/app/magic-micro-battle-arena/id908075215?mt=8

https://itunes.apple.com/us/app/qube-crush-3d/id905380169?mt=8

If you don’t have an iOS device, wait for an Android update, or check out a video of Qube Crush here:

https://everyplay.com/videos/7850308

*) Yes, I know what I’ve previously said about “free apps”, I still think it’s a fundamentally bad idea, but the sad fact of the matter seems to be that as an unknown IP or small game developer you are left with a choice between “free” and, well, nothing else at all… So much for not being part of the problem, though.