Monday, October 22, 2007

On Prefix and Postfix Increment Operators

For those familiar with increment operators and their prefix and postfix usage skip down to just below the pseudo-code.

When you have a number and you want to increment it while stepping through a collection or something you can use the increment operator ("++"). That will add one to whatever number you pair with the operator. When using increment operators there are prefix and postfix forms. The prefix form is when you put the operator before the variable containing the number and the postfix is afterwards (++i vs. i++). Functionally these the placement results in very different functionality, if you use the prefix form then the number is incremented before it is evaluated whereas if you use postfix then it is evaluated after it's value is used. In other words (this is really simplified pseudo-code):

variable n = 0;
print n;
print n;

Will print the number 00.

variable n = 0;
print ++n;
print n;

Will print 11.

variable n = 0;
print n++;
print n;

Will print 01.

Awesome, let's continue.

The issue I have with this is that I can only use one at a time. I just came across a scenario where I actually got kind of excited about a line of code I had just written (which doesn't happen very often). The scenario was that I had a string containing tokens I needed however each token I needed was surrounded on both sides by tokens that I don't need. So I had something like:


This led me to writing the following lines of code:

for (int i = 0; i < tokens.Length; i++) {
  string token = tokens[++i++];
  Trace("Found Token: " + token);

Sadly the compiler informed me that what I had done is totally not allowed. Which made me sad. Because ++i++ looks awesome. And yes, I do realize that I'm a huge dork.

Tuesday, October 16, 2007

Freelance Finances

While I'm waiting for a 175mb SDK to download I thought I'd update since it's been a while.

Last month I brought in about a third of what I was bringing in at my former real job. This month is looking like it'll be a little more but it might not be by much. While I can have a month or two like this I don't know that I can have 3 months in a row like this. Savings can certainly help support us but that's not their intended usage. There are several things that I think I've learned or that have been reinforced by the current lack of extra funding:

Save In Times Of Plenty
I'm really good at spending money. REALLY good at it. It's really easy to look at your bank account balance and justify some purchase or another since you have the money when in reality you're not going to get a whole lot of use out of something. Having money saved away will help get through the sparse times.

Lower Your Standards
One thing I struggle with is pride. Especially when it comes to the things I have. This is especially true of the car that I drive. We have a Mini Cooper that we recently paid off. It's nice having it paid off (and certainly helps for months when I'm not bringing in a whole lot) but we're still paying more on insurance and it's expensive to maintain since it's more or less a BMW. My car has been a source of pride since I finished college and got a shiny new Subaru WRX.

All that said I don't need it. I don't need to spend money on every shiny object that catches my eye.

Re-Evaluate Your Priorities
This whole freelancing thing didn't start out as a way to make huge amounts of money. It would be nice if it started making me huge amounts of money but that's not one of the primary goals. I need to try to remember the other benefits of freelancing and weigh those into decisions that I make about my employment. What're the other benefits? I have so SO much more freedom with my time. I'm learning a whole lot in a variety of technologies. I'm my boss, if I'm working on projects that I don't like or don't like working with a specific client I don't have to. Overall I'm more in control of my time and how I spend it.

My download is done, back to work.