rc3.org

Strong opinions, weakly held

Tag: software development (page 12 of 16)

A simple rule of thumb

I was looking at some code and a simple rule just occurred to me. If you’re creating an object oriented system, any time you start writing a method that accepts an instance of a class that you created as an argument, you should ask yourself whether that method should really be a member of the object being passed in as an argument.

I’d also recommend that any time you’re asking a question about an object (in a loop condition or an if statement, for example), it’s worth considering whether that logic should be encapsulated as a method of the object as well.

For example, you might have code like this:

if (person.getAge() > 18 && person.getCountryOfBirth().equals(Country.USA)) {
    // allow person to vote
}

It should probably be written like this:

if (person.isEligibleToVote()) {
    // allow person to vote
}

The second example is easier to read and makes it easier to avoid keeping the voter eligibility conditions in more than one place. For example, I know that someone is going to file a bug noting that my expression doesn’t account for naturalized citizens. Keeping that logic in its own method will make it easier to fix that bug.

Links from January 25th

Learn to think like a programmer

Tom Armitage explains how to think like a programmer. I would recommend this article to some programmers I’ve interviewed.

Data breach notification laws

Bruce Schneier argues that data breach notification laws are a good idea. I’d agree. I was working on an application that stored personal information when the ChoicePoint breach was reported, and it changed the way I thought about how much data we should archive. As Schneier points out, most identity theft results from computers belonging to individuals being compromised, but companies that deal in bulk amounts of user data should be particularly responsible when it comes to safeguarding that data. Without such laws, I don’t think they’d be as careful.

On practice

Tim O’Reilly posted a transcript of a long email thread among O’Reilly personnel on the subject of practice. It’s a wide ranging discussion on the value of practice and how people learn among people whose job it is to teach (usually through books).

One thing I’ll add is that practice by itself is almost never as effective as it is with a good coach or teammates who can offer useful feedback. I’ve seen programmers who have written huge amounts of code over the years in isolation who progress very little in their overall skills. That’s why even someone like Tiger Woods, who knows as much as anyone in the world about how to play golf, still has a coach. He needs someone who can help him catch problems that would take him a lot longer to notice on his own.

For more on this, I’d recommend Jason Kottke’s posts on deliberate practice. I’ve considered trying to apply the concept of deliberate practice to being a better arena player in World of Warcraft, but frankly I just haven’t been interested enough to put in the effort.

I also found one bit interesting, this point by Kurt Kagle:

Practice is necessary to learn a skill (it takes about a million repetitions, typically around ten years to master any given skill), but I think that we have become so fixated upon this necessity that we have to question if the skills that we are spending so much of our time and resource educating them are ones that they truly need.

If our children are going to live in a world heavily dominated by computer technology, is it worthwhile for us to be practicing skills that we’ll only use a handful of times in our life?

His specific example is mathematical calculations that are easily performed by a computer. I think I’d argue that we need to know them well enough to understand what’s going on behind the scenes in the computer. Why? Leaky abstractions.

Irritation is my muse

I was recently asked to make a really irritating change to a report. This seemingly minor change makes the code significantly more complex, hurts performance, and will force me to add some really ugly code to what should be a very simple page.

Because I find working on this feature so distasteful, I have been procrastinating even looking at it for a couple of days. When I woke up this morning, I had an inspired idea for fixing this problem in the long term. I’m still going to have to write some ugly code now, but I’ve got a solution in mind that will enable me to get rid of that ugly code and a whole bunch of other really nasty code along with it.

What I realized is that one of my most reliable inspirations for good ideas is being backed into an inelegant solution to a problem. When I have a requirement to satisfy and the only way I can think of to fix it is hackish, I sometimes can’t even make myself start working the problem until a workable long term solution occurs to me. I don’t know if it’s an ideal creative process, but it works well for me.

Rails and Rack and Metal

I make pessimistic pronouncements about Ruby and suddenly interesting things turn up.

What’s Ruby’s future?

I’ve had a blog post about Ruby sort of simmering on the back burner, but I haven’t written it because I don’t really feel qualified enough to substantiate the case that I wanted to make. As so often happens, somebody else has beaten me to the punch and written something much like I had in mind.

In this case, it’s KirinDave, who explains his suspicion that Ruby is a soft of dead end. There’s a funny thing about programming languages. They’re some of the only pieces of software that really seem to eventually be finished. Perl has seemed finished for a long time. I suspect that Python may be finished. C has been finished forever. Ruby, at times, seems over but not finished, if you get my meaning.

On the other hand, I find programming in Ruby enjoyable and educational, so it’s not like I’m looking to give up. It’s just that even after a couple of years of doing it, I still feel like we’re dating rather than married.

Web site CPU usage

Brent Simmons says that developers should profile their Web pages to see how they affect the CPU usage on end user computers. My wife uses an iMac G5, and I can tell which Web sites she’s using based on how loud the fan is. There are plenty of Web sites that keep the fan running all the time, even if she walks away from the computer. This is an area of Web development that has been ignored but should not be.

How reporters are like developers

I couldn’t help but chuckle when I read this:

To the old-school reporter, “listen to the customer” is assumed to be code for one of the following: (a) cave to the politician; (b) coddle the advertiser; (c) pander to the ignorant; or (d) give credence to the crazies.

This mentality has served newspapers poorly, and it serves developers poorly too, but it’s very difficult to overcome.

Older posts Newer posts

© 2025 rc3.org

Theme by Anders NorenUp ↑