The Var Hungarian

 

I was reading a blog post from one of my favorite software bloggers, Joel Spolsky, and came upon the middle of the article (http://www.joelonsoftware.com/articles/Wrong.html) where he talks about Hungarian notation.  I was floored because I, too, had been brainwashed by what I thought was the intent of the notation.  It turns out that what everyone thinks it’s for (knowing what kind of variable something is or how a function might work) was not the original intent and use.  It was really for telling you what the variable DID and what it stood for, to make you less likely to make a mistake in coding.  Seriously, read the article, then come back here, I can wait a few minutes….  At the very least, go there and find the section marked “I’m Hungary” and read that.

So, you probably just learned that we’ve bastardized a pretty useful concept because of bad documentation (that’s a story for another day).  But, you’ve also probably gotten a seed in your brain that maybe you can help fix some of the insidious bugs that pop up in your own code.  Or, maybe just a way that you could write code to make it easier to return to sometime later and understand better, or how to train new coders in what your code does.

I’ve always been an advocate of straightforward code.  Nothing too clever (sometimes I do and sometimes it works, and sometimes it doesn’t), but the point is, someone should be able to come by, look at my code, my functions, and the data, and figure out how to muck with it or use it without needing therapy afterwards. 

The latest craze in C# programming is the use of the keyword “var”, which suddenly stands for “there’s no need to actually type ‘int’ even when that’s what a variable is.”  I understand that it’s necessary for queries and can eliminate some duplication of typing of complicated templated types, like Dictionary<List<int>, double>, but some people go too far.  Intellisense can help with the discovery of variable types, but nothing beats looking at code and being able to see what type something really is (especially when you actually know what it is) to be able to understand the code without having to highlight every variable and figure out (then remember what it is).

The same thing can be said of clever C or C++ macros which can just as easily be done with functions.  Seriously, this is what the “inline” keyword was made for and if that doesn’t work for you, then just incur the function call overhead unless you’re writing realtime software or something that’s so time critical that there’s no other way to do it.  Otherwise, every single person who looks at that code (including you six months later) is going to have to search all of the header files wondering where the code is because your IDE (or worse, linux’s gedit) sure as heck won’t tell you.

Simple, straightforward code – your New Year’s resolution.  And mine.

There is no U in team

In my book, I included a section with the above title.  It means that you’ve been fired, or maybe just laid off.  Note: If you like the phrase and want to reuse it, give me credit as I believe I’m the first to use it.

Losing your job isn’t easy.  OK, it sucks.  There are many situations that can get you there and many ways that it can actually happen, but either way, you find yourself unemployed.  The question now isn’t what happened, it’s what happens next.

First, don’t burn any bridges.  Seriously.  Don’t badmouth the company or the people in public.  You may find that years later, you have an opportunity to return under different circumstances and you don’t want to rule that out just because you’re angry now.

Next, negotiate the best severance package possible.  The default package from your employer isn’t set in stone.  You may be able to get more money by getting your vacation time added to your monetary package, or you may be able to talk them into extending your health care for an extra month or more.  It can’t hurt to ask.

Of course, apply for unemployment insurance.  Unless you’re positive that you’ll have another job in no time at all, start the process.  You may have to wait a month or two, but do the research and get started on the paperwork (or web forms).

Now comes the hard part: evaluating what happened.  This can happen in a variety of circumstances and they’re all different.  For example, let’s say your whole group was laid off from your company because they weren’t paying for themselves.  I used to work for a company that was notorious for creating “strategic” projects and products.  Unfortunately, those projects were often free to customers and that made the group a red line on someone’s budget.  Want to guess who might be the first group to go when the upper management needed to cut expenses?  Suddenly strategy wasn’t as important and making money.  If your company does this, think twice about being part of that group unless you can constantly justify its continued existence.

If you’ve been fired, you have a different set of problems.  The first thing to do is accept some responsibility for your own part.  Even if your boss was a complete jerk, you couldn’t find a way to work out the situation or keep your head down or manipulate him/her or get a transfer.  It takes two people to create a problem.  To be fair, sometimes your boss does have it in for you, but that’s life, unfortunately.  If you’re still alive and not physically or horribly emotionally scarred, then you’re going to have to get past it.  When emotional issues arise, take some time to write down your thoughts and feelings.  The book “59 seconds” says that research shows that writing down your feelings is better than talking with someone about them.  Either way, a little emotional healing will get you ready to get back to work.

Your job now is to find a job.  Treat it like that.  Start hitting the newspaper, internet, and personal network.  Get past the HR department and get the name of the hiring manager.  Remember that at some point (hopefully most of the time) you were and are a rock star developer.  Your experiences have made you who you are and you’ve learned from them.  Even if you lost your last job because you started to lose your passion, you can find it again with a new opportunity, in a new company, with new people and new challenges.  Now get going.

Multiplicity

All day I’ve been seeing the same post from my friends on facebook: Please do me a favor, just hover over my name and click a few things so that you won’t see my comments to other posts in your ticker window.

I finally got the point where I realized how silly this whole thing is and came to a decision point: Am I really going to do this on all of my friends’ posts and ask them to do the same for me?  What if I had over 1000 friends like some people I know?  I seem to recall that before the latest changes, I might comments from my friends, just not on posts by people that aren’t my friends.

Anyway, the real point is that this whole thing is backwards.  What’s the point in my sending you a message, asking you to do something so you can’t see what I’m writing somewhere else?  Shouldn’t I have the control over this, not you?  This whole fiasco is pointing out a flaw in the user interface for facebook – at least as far as their users are concerned.  The people who run facebook are probably perfectly happy with how they set it up, but with all of the posts regarding this, they may be rethinking their decision.

So, how does this affect you and your decisions in your work?  The first question to ask yourself when producing something for public use, be it a software application, website, phone menu, ATM, etc., is to consider two things: proper default values and minimal interactions.

Choosing proper default values means that you decide, possibly with the input of your user test group, what the most likely choice will be for a particular option, then make that choice the default.  If done correctly, your users won’t even need to know there’s a choice, since you’re already doing the right thing in their minds.

Minimal interactions is what this facebook issue really brings up.  How many people are going to have to click on how many buttons to accomplish what they want to do?  The more clicks and the more people who have to worry about them, the more disgruntled your users become.  Of course, we always want to provide our users the most flexibility and that often means making multiple choices along the way, but if your users have to repeat the same operations or there’s a most likely path, either storing their preferences or providing a shortcut will make them happy.  And instead of complaining, they’ll tell others how easy it is to use your application.

 

Who’s Out First?

I’ve been involved with many projects and products over the years.  Some have been true innovations – the first product of its kind.  Most have been products created to compete in a market where there already is competition.  Let’s face it, the latter case is the more common.  How many times do you see a new product come out, hardware or software, that’s really different than its predecessors or defines a whole new category?

What made me think of this? I was perusing some software blogs and I ran into one where there was a picture of a Windows Phone.  I’ve never played with one before, but it hit me that the iPhone defines the category now.  It really shouldn’t have – Palm owned this market from the beginning (I used to carry a Palm Pilot, then they added phone capabilities to it), then Blackberries (RIM) came along.  The iPhone didn’t start it all, they just did it better – well integrated, great marketing, and sleek design.  The iPod was new and nobody has topped that yet.  My daughter bought a competitive product and it was ok, but using Windows Media Player instead of iTunes was a drag.  Again, much better integration and better design.

The iPad wasn’t the first tablet, but it was.  The Windows-based OS for tablet PC and the hardware that accompanied it wasn’t significantly better than a PC with a Wacom tablet for pen-based drawing.  The iPad started from the other direction, not by modifying what already existed, but starting over (having the iPhone’s OS certainly helped).

This brings me to software.  How long has facebook been around and how many users does it have?  Can Google+ just sweep in with some new functionality and take over?  Facebook stole the world from MySpace, so why not?

The question to ask is: Where is my product?  Is it the market leader?  If so, are we complacent or constantly improving?  Are we the start-up, making something to beat the current market leader?  If so, do we have the story that makes people want to switch?

Even if you’re a young software developer, you should start asking yourself these questions.  Not only will you learn something about your company, its goal, and its marketing, but you may also decide it’s time to look somewhere else for a future that has more potential.

Breaking iNews

July 21, 2011 Federal Court in Sacramento, CA.

After being sued over the use of the product name iCloud by an Arizona VoIP company, Apple Inc. fired back.Apple filed a trademark application in federal court for any word beginning with the letter i, including the word I.  Before a patent judge, Apple attorney Theodore Buttress argued, “Clearly, with the iPod, iPad, iPhone, we have established a precedent.  Other words beginning with i evoke Apple products.  Therefore, we believe that we are within our rights to trademark the letter, within reasonable limits.”  When the honorable Johnson N. Johnson asked what ordinary folks were supposed to do to avoid violating the trademark, Buttress suggested that people consider replacing the word with E, since that is unused in common English.

Buttress continued, “We have already contacted the Oxford English dictionary, which has already shown a propensity for allowing changes and additions to the language.  We suggested that they could move innovate, irregular, imagine, etc. also to the letter ‘e’.  While this seemed excessive to them, they agreed that it was doable.  They also readily agreed that irregardless was an abomination and that anyone who used it should be sued regardless [Buttress used finger quotes in court] of the ruling.”

Judge Johnson replied, “I’ll [he smiled when he said the word] take it under advisement.”  Johnson promised to return a decision “real soon now.”

Bad Investments

This is not your ordinary coding-related post, so bear with me.  My daughter received a monetary gift many years ago.  It was invested in a bank in Ohio and she wasn’t allowed to touch it until she turned 18.  It wasn’t a huge sum, but it wasn’t $10 either.  Here’s what happened.  Let’s use a starting point of $1000 as an example.  After 11 years in the bank, a very safe place to put your money, it was worth $1170.  That’s a tidy increase of $170.

Not so fast, though.  The S&P 500 went up around 2.7% over that time.  If the money had gone in there, she’d have $1341 now.  What about a balanced mutual fund?  The Fidelity Puritan Fund went up an average of 5.2% per year, which would have given her $1747 now.

It gets even better when you add inflation.  The cumulative rate of inflation over the same period was 34%.  If you had invested in the S&P 500 over that time (it was a rocky up and down time) you’d still be even with inflation.  In the Puritan Fund, you’d still be ahead.  In the bank, you’d actually have lost money.

So, why am I giving you this little lecture?  Because I used to work with a group of developers who were afraid of the stock market.  They kept their money in the bank in safe investments.  And they were going to lose a lot of money due to inflation, which is the hard part to detect.  Interest rates in bank savings accounts are less than 1% right now and CDs aren’t much better.  Meanwhile the stock market has been on a tear since the recession has eased.

Your best strategy for retirement is a mix of investments in stocks, bonds, commodities, etc. and thinking for the long haul.  Try investing in one of the newer “retirement date” funds that some firms have now.  You pick a year for your retirement and they adjust the mix of stocks and bonds for you.  It couldn’t be simpler.  And you might actually retire with something to live on.

 

Financial Incentives

Recently, I worked on a Linux-based project.  After spending most of my recent years in Windows land, it was interesting to see where Linux has gone.  Yes, there are some visual tools so you don’t have to ls and cd your way around the file system if you don’t want to.  Yes, there’s a nice way to install software (thank goodness).  There are even some decent applications for code development.

But, what struck me was the overall clunkiness of the environment.  I still hear people talk about setting up a Linux box for their home and I don’t get it.  It’s capable and secure, but the average home user would be lost.  It’s an environment for people who like to, or need to, tinker with the engine themselves.

This brings me to my point.  I see Linux as the largest example of open source software.  It has lots of functionality and tons of contributors.  However, how many times have you downloaded an open source project or freeware in any environment, just to discover that the support has disappeared a year ago.  It’s interesting because sometimes a project like this is the only thing that fits your problem well, but when the support disappears, you’re out of luck.  I started using a java user interface toolkit that was amazing, but the developer just shut the project down and I can’t even find the documentation online anymore.

I believe the answer is in the lack of financial incentive.  For all the talk of the greater good and free software (for which I’m very grateful), the quality and support is usually better when someone is trying to make a living producing it than when it’s just a pet project.

The next time you’re sitting at work, writing code for a living, think about what you owe to your employer who’s paying your salary and benefits, and the users, who rely on your software.  Or think about the potential users, whom you are trying to lure into buying your software.  If there’s money involved, will this change your attitude on how you work?

Who’s Your Data?

I’ve worked on a lot of different projects and products over the years.  Most of these have been PC-based, file-based storage, applications.  The latest project I’ve been working on has been similar, except that its data is stored in a database.  My colleague, Steve, and I were talking about global data recently, and it got me to thinking about the some of the more horribly structured projects I’ve worked on in the past.

Now, envision that you’re new to a project that’s been in the works for a few years.  There have been a couple of revisions released to the public.  The code has patches scattered around it, copied and pasted code, sparse comments, and data and operation code are intermixed.  In order to write new code, you not only need to understand the data, but the hierarchy of objects that contain the data.  Storing this in files is a recursive process that filters through object after object.  Touch something and something else breaks.  Sounds like most code you’ve worked on, doesn’t it?

Again, envision this code, but with the data stored separate from the operations on the data.  Sounds a bit like Model-View-Control doesn’t it?  Well, even if you aren’t working on something that’s well laid out in a nice, interface-based, MVC pattern, or you want to build something that’s quick and less painful, or you want to migrate some of your code to something similar, a global data area might solve your problem.

I’m not talking about a wad of global variable strewn all over the place (that’s a mess).  I am talking about an in-memory database, with structured information.  In other words, the information that you need to save could be stored in a set of arrays, classes, or structures, that do nothing but hold the information.  All of the other work would be done by other classes.  Think how easily you could write new code to operate on the data without interfering with the other classes that operate on it.  Think how easy it would be to find data.  Think how easily you can implement persistence (save and load).  This could be a simple step in cleaning up some of the spaghetti that’s already in your code-base.

Motivation Part 1

And if you cover it with enough sauce, no one will notice.

Extra Conditioning for your Career

dctr

Really, it’s all in here.  I don’t do an enormous amount of hawking my book on this site, but the other day, I realized that I’m doing a disservice by not pushing you into buying it.  Why?  It’s not because I want your money.  Buy it from Amazon for only $18.96 and it will pay for itself.  How does it pay for itself?  I’ll enumerate some of the reasons:

  • Don’t screw up another interview, get the next job you apply for.
  • Once you get offered the job, you’ll get a better salary and/or benefits by using some of my tips for tactful negotiation.
  • You’ll improve your organization with your leadership skills you get by following some of the ideas on organizational and personal habits.
  • You’ll keep your nose clean by avoiding risky practices that can get you in trouble with human resources and management.
  • You’ll understand marketing and sales better and learn to work more effectively with them by understanding that it’s a partnership, not a leash.
  • Your place in the software organization will improve because you’ll realize that it’s not just your coding that counts, it’s the intangibles as well.

It took me a long time to realize that my biggest benefit to my employers wasn’t my coding skills, but my leadership and big picture knowledge.  The sooner you read this book and come to the same realization, the sooner your career takes another step forward.

Next Page »