Archive for October, 2006

Barack Obama is (not) the Antichrist

October 25, 2006

Things that makes me sad:

  1. That people believe in the antichrist
  2. That some believe it is Barack Obama

Blogging is Evil

October 15, 2006

According to the Restored Church of God blog, blogging is evil. Some choice quotes:

In effect, personal blogs are becoming a shopping catalog for pedophiles!

Because this article is extremely important, some may need to read it twice and use it as a stepping stone to further study on this subject.

Whether or not it is effective, as soon as something is posted the person has a larger voice. It often makes the blogger feel good or makes him feel as if his opinion counts—when it is mostly mindless blather!

Stop and consider. The biggest mark you will ever make is to build God’s character and be born into the God Family. Blogging will not help you achieve this.

This makes me sad. Is a god so pathetic that he needs us to build his character worthy of worship?

If you post mundane details of your life, you are in effect saying that your life is important and that people should read about it.

My life is important. So is yours.

One blog by a young twentysomething in a splinter used the acronym “OMG,” which is a shorthand way to take God’s name in vain … There should never be a need to use slang or any type of wrong words.

How do you think God feels about the mindless blogging that is occurring?

I don’t think any gods would give a damn. I certainly wouldn’t were I omnipotent.

“I used to wait tables at Hooters”! Although she may not have been familiar with God’s Way at the time of that employment, and so may not have known that this was wrong, she still should be discreet.

It’s wrong to tell people you used to work at Hooters?

Some say illicit drugs are therapeutic—does that mean they should be used? Obviously not.

Not obvious at all.

We must do everything in our power to be concerned with how we appear to others. If they come to the wrong conclusion, it may hurt your reputation or badly reflect on God’s people.

Let me emphasize that no one—including adults—should have a blog or personal website

What a stupid goddamn religion.

Six Easy Tips for More Maintainable Code

October 8, 2006

I’ve recently had the opportunity to work with a large, unfamiliar code-base. The experience has made me reflect on some of my own coding practices and on writing more maintainable code. Much has been written on this topic, but here are the things that I feel are most important and have a high payoff without much (if any) additional work.

Make use of inherent metadata

Programming languages have inherent metadata in how you name things, what types you use, scoping, visibility, etc. This information is invaluable for someone new looking at the code and helps make the code self-documenting. There are several things you can do here:

Use good names

  1. Give classes, variables, methods, functions, etc. descriptive, differentiable names. Things that are related should have similar names, while things that are not should not.
  2. Keep the names up-to-date. If functionality changes, update the name.
  3. Variables with different scopes should be differentiated. For example, prefix instance variables with an underscore.
  4. Be consistent.
  5. Don’t create variables for things you only use once – just put them inline. Then I don’t have to figure out where else the variable is used.

Use appropriate types

  1. If possible, don’t use multi-level typedefs. It’s a real pain in the ass to go through 5 header files to figure out that foo_bar is an unsigned integer. And don’t typedef pointers away – I want to know if something is a pointer or not. Especially don’t typedef pointers away by inventing your own syntax (e.g. CFArrayRef is a CFArray pointer). The language already has syntax for that.
  2. Do use typedefs for things like enums.
  3. Use the most-specific type possible. If something should not be negative, make it unsigned, etc.

Use appropriate visibility

If something should only be used within a class, make it private. People looking at the code then don’t need to worry about external clients.

Keep things short

Nothing is more depressing than trying to grok a long method/function/class. There shouldn’t be hard rules on length, but I try to write methods/functions that fit on one screen, and to keep my classes under around 1000 lines of code. Without caution, this can lead to a method/class explosion, but I’d rather grok a small class cluster than one gigantic class.

Keep block nesting to a minimum

Don’t have a while loop inside an if, inside an else, inside a for loop, inside an else if, inside an do/while loop, inside a …

Reduce coupling

If I have to understand more than a small portion of the code to change one class, there is a problem.

Write useful documentation

You don’t need a lot. Here is what I think is important:

  1. Describe briefly what a method/function does. No method or function should be so complicated that this is more than a sentence or two.
  2. If a method is overriding a superclass, note that and explain why.
  3. Explain anything unusual or complicated.
  4. If a method has concurrency issues (should only run on the main thread, etc), note those.

Think of those that come after you

Whenever you write some code, try to put yourself in the shoes of the next programmer to work on the code. This is the programmer’s version of the seven generations rule.