Thursday, July 17, 2008

Why you shouldn't be a developer

So, I just got through telling you to learn how to write a bit of code. Maybe you tried it out and thought, hey, this is easy! Developing is easy money!

Stop. Just... Stop.

Coding, like cooking, is easy to do when you're not doing much. Anyone can boil an egg, or slap together a cake from a mix. A developer worth his or her salt isn't doing that.

Coding is more than knowing python or C or Java. It's a way of thinking. You have to be able to break things down into their component parts. It's being able to put parts back together again in ways that still make sense.

The best developers I know may prefer one language, but if you held a gun to their head, they could pull a few more out of their hat. If you handed them a language they'd never seen before, most could get up to speed fairly quickly if they needed to. We have our favorites, but the dark truth of the good developers is that if you needed them to program in their most hated language... they probably could. Hell, they see career development as being able to take languages OFF their roster, and still land good jobs.

Back in the dot com heyday, I was in the 'make it or break it' course for computer science: Data Structures. It was required by all students, and was a requirement for all classes after it. You didn't pass it, well, there was always Communications... I made the acquaintance of a guy who was struggling. Badly. He didn't understand object oriented design, or design patterns, or reuse. He could write C++, but he couldn't think in it. All semester I babied him in exchange for free food and sodas, and somehow, by some miracle, he passed. He memorized all the procedures and right answers and, in Rainman style, spit them back out at test time.

The prof saw how much he struggled, and on the last day, pulled him aside.

"Why do you want to do programming?"

"Um... money?"

"Fair enough." He lowered his glasses and gave him that look they teach you in professoring school: the kind that bores through your skull.

"I hope you like Ramen."

He switched to communications.

Tuesday, July 15, 2008

Why you should learn to write code

Yes, you.

There hasn't been a job yet in my repertoire that wasn't improved by a bit of code. Oddly enough (or sensibly enough, as you'll see) the parts that weren't improved weren't the more cognitively demanding areas of these jobs. It was the dull parts where ten lines of script helped me out beyond belief.

Real life example: we have to upload our code for every project into a repository that resides offsite. Due to a few business rules, we can't just ftp files over, or give them SVN checkout permission to our servers. Not a huge issue, really, since code bases are usually pretty small.

Cue the day I handed over a product that, due to images, video, and flash, was over a gig.

  1. It belonged to the project with monthly releases.
  2. And each release had to have it's own directory in the server.
  3. Did I mention that there was a file size limit for uploads?

I really thought the code manager was going to cry.

We came to the compromise that I would do deltas for him. Each month, I'd bring over only the files that had changed, with file structure preserved. That way, if they did have to pull the code out and redeploy it, he could just cut and paste the latest delta over the first release and hand it over. Doing this by hand? A bitch. Doing it with python and subversion?

A snap.

I had SVN create a file called diff.txt that gave me a list of every file that had changed between this release and our first. Then I wrote a python script that either copied a file into a new folder if it had been added or modified, or made a note in a file called deleted.txt if it had been deleted.

Writing it took me a few hours. Running it takes minutes. Every release, it saves me god knows how many hours of cutting and pasting.

You don't need to make megapiles of script for code to be useful. My useful script, including a probably over done open and read file function, was under 50 lines.

I started off with the advantage of having learned how to program in high school and a bit in college, but I do believe anyone can learn to code. Python is a great place to start. It's light, fast, free, and has a strong community. A few places to start:


I'm a lady of my word, so here's the code:
import os
import shutil

def openFile (filename):
"""Given a filename, read the contents of that file.
"""
f = open(filename)
line = ''
a = []

while 1==1:
line = f.readline()
if line != '':
if line != '\n':
a.append(line)
else:
break
f.close()
return a

def moveFiles (array, base_path):
'''For each different file:
1. Make sure that the directory structure is there.
2. Copy the file over.
'''
deleted_files = []
for line in array:
files = line.rsplit()
if files[0] != "D":
orgfile = base + files[1]
files[1] = "deltas/" + files[1]
newfile = files[1]
newfile = newfile.rsplit("/")
newfile.pop()
dir = ""
for folder in newfile:
if dir == "":
dir = folder + "/"
else:
dir = dir + folder + "/"
try:
os.makedirs(dir)