-
Coding tip for if statements
When I was a young engineer, a more senior colleague of mine taught me a lot about writing code and helped me adopt my own style. Just like an artist, every developer has his own style with no style being wrong. However, there is one coding convention that he taught me I think all developers should use. Here's what developers shouldn't do:
if (something) dosomething;
Instead they should do:
if (something) { dosomething; }
(or if you prefer, put the { on the if line).
Why do I say is? It's simple, if you come along later and add a line to the first statement, like:
if (something) dosomething; dosomethingelse;
you could have the wrong thing happen. If you wanted the "dosomethingelse" to only happen if the if statement was executed, that's not what would happen (it would always execute). The brackets make it explicit what will happen on the if statement. I've seen this type of coding in a lot of code and it will definitely lead to failure at some point or another.
I'm sure some people will take offensive with what I say, but this tip will save lots of time in debugging at some point.
-
Managing Multiple iPhone Developer Certificates
Back in the dark ages of iPhone development, being part of 2 separate iPhone development teams was problematic as Xcode didn't deal with multiple developer certificates too well. Now Xcode will automatically select the right certificate (it took me awhile to find a reference).
Each developer certificate now has a unique hex value at the end which lets you have 2 certificates for the same developer. However, until today, I never managed to get this to work properly. It turns out that in order to make things easier, instead of following Apple's directions to create a certificate signing request, I control clicked on the private key I created for the first certificate and selected 'Request a Certificate from a Certificate Authority With "iPhone Developer Private Key (Scott Gruby)'.
After that I was able to create my second certificate and have it associated with the same private key (I don't think Xcode likes 2 different keys to have the same name). I'm not sure if this was absolutely necessary or if changes to how Apple generates certificates and changes to Xcode made things easier, but I'm not going to complain. I now can debug apps for multiple teams without having to change the bundle identifier and possibly make a mistake and check it into source control.
-
Easy version numbering in projects
When I start all of my projects, I do a few things to make version numbering easy.
First, I create a Defines.h file that looks something like this:
#ifdef INFO_PLIST #define STRINGIFY(_x) _x #else #define STRINGIFY(_x) # _x #endif
-
First week of self-employment
Now that I've been self-employed for almost a week (Monday was my last day at my job), I feel like my life has changed a bit. There was nothing wrong with my old company or my old job, except that it just wasn't for me. Prior to taking the job, I spent 5.5 years self-employed, so I really got used to the freedom and being my own boss. I feel like I'm back in control of my work as I have a schedule for one of my projects (or will soon) which will let me figure out when I need to work really hard and when I can work at a normal pace. In the world of software, most projects have schedules which helps in planning a workload. In the world of IT, there may be projects with schedules, but there always will be things that have to get done immediately (someone can't get to a server or a computer doesn't work; you can't schedule those things in or delay fixing them).
Things seem to be much calmer as I start my day around 9 am and end around 5 pm; before when I got up, there seemed to always be something going on when I first checked my email at 7 am (also partly because almost everyone I worked with was 2 hours ahead). In addition, in this first week, I feel like I'm making progress towards a goal (the ship date for the current phase of my project).
This may be my "honeymoon" phase of being self-employed, so my excitement may wear down. However, I'm going to do my best to keep a positive attitude and make it so that my job doesn't take over my life. I know that this isn't easy to do, but it's a goal that I'm making for myself.
If I ever decide to work for someone else, I need to look back on this post and evaluate if that is for me.