Quantum Tea

Thoughts

Code Conventions

Maybe I just had a strange introduction to programming. After spending a couple of years at university writing FORTRAN 77 code with lines like "hedgehog + womble = noodle/27," I ended up in the Real World and had to change the way I wrote. The eye opener was a piece of FORTRAN code called Erratic, which implemented the equations from the IEEE 287 standard. My task was to make it work, and document it.

Erratic didn't compile when I first got it, and it didn't have any code comments in. After I'd memorised IEEE 287, I still had very little idea of what was going on. I memorised Erratic, and that didn't help much either. The only way to work out what was happening was to go through every line of the program and work out what it did, which variables went where, and which part of the standard it was calculating. The program was a sprawling mess of spaghetti code, looping all over the place, with odd variable names and some gnarly equations split over several lines.

To me, code is a conversation between two programmers. One is the original author, the other is a separated from him or her by space and/or time. My code from 6 months ago is a conversation between me now, and me six months ago. Two coders, separated in time.

If you know some poor sucker will have to wade through your code later, you write it differently. If you have a suspicion that poor sucker will be you, you're extra careful to make it legible and understandable, put in comments and document it. My code is written assuming I'll be back in 6 months time and forgotten all about it.

The other formative influence on my coding style was the first set of Visual Basic programs I wrote. The company was assessing VB for potential future use and wanted a set of example database access programs, written by the lowly intern. I had to write those programs for someone who didn't know VB, and whose native language wasn't English. She was supposed to learn from my code and write the real database system. I spent months trying to work out how I could use every VB control going, to show how it's done.

Now, I have an open source Java project going on. I know how often the source code has been downloaded, and it's roughly one download a day for the last six months. Total strangers are going through my code, ripping out the bits they don't like, using the bits they do in other programs, changing the things that irk them. And that's fine.

So I have trouble understanding why people get so protective of their code. It's only code after all, not life threatening industrial secrets. Refusing to let other members of a development team see your code is counter productive. The more eyes looking at the code, the faster the bugs are weeded out. When you have a horizontal development model, it's essential that the people on the other bands get to see how you've done your bit, so their bits can plug in correctly. Horizontal development is where one person does all the GUI work, another does all the database stuff, another does the data processing layer and so on. Vertical development gives each developer one component to work on from start to finish, GUI to back end. Vertical development makes more sense to me than horizontal, probably because that's what the solo developer does.

But if code is a kind of conversation, is it free speech? No. It's a tool, assembled to do a specific task. Everyone on a development team should be able to see each other's code, if only to learn new ideas from it. Whether that knowledge goes outside the company is another matter. It would be nice if you got the code along with the program, but it's unlikely that Microsoft will ever release the Windows source code. They didn't write it for outsiders to see, so it may be really ugly code inside. I like to see other people's code because I'm still learning. It's really satisfying to say "So that's how they did that nifty trick, wonder if I can use that somewhere?"

I'm not rabidly opposed to companies that keep their source private, but the way I learnt to program is far more open source than not. And I think that's a good thing.

 

Home. Copyright © Alison Hawke 2008. All rights reserved.

Home page.

        [home]


Site   Blog
Blog
What's happening.
Read this first

Blog Archive
What already
happened.

Thoughts
The way things are

Humour
Laugh. Or not.

Desk Drawer
Odds and ends, random stuff.

Knitting
Knitting and spinning,
with knit links.

Disclaimer
Not my fault.

Caffeinated Bliss home.
Caffeinated Bliss