Category Archives: languages

Shell: ‘seq’ generates a range of numbers

I don’t use this often, but I keep forgetting it – probably because I don’t use it often.

$ seq 146 151

Too long is too bad

Long is good. Too long is too bad.

Steve McConnell tells us in Code Complete, that long variable names are good. I think it’s in the section on “Self-documenting code”.

In object oriented languages, you have the object name, the name of a possible sub-object, and the name of a particular field or item in the object, which all add up to a descriptive long name, but split into different parts.

Example: mypack.special-effect.color = chartreuse

However, I have been working in Gnu Make lately. Gnu Make recommends that you only use numbers, letters, and underscores in Make, as other characters may be used for other special purposes now or in the future. Now, in Gnu Make, you don’t have real objects. You do have “constructed variables”. By using recipes with wildcards in them, and constructing variable names with pattern substitution, you can get some of the same effect as objects. However, the variable names look kinda ugly.

Example: testset_special_effect_color = chartreuse

Its easy in make to get a few lines like the following. The intent here is to make a copy of one pseudo-object that will only be used when code coverage is in effect:

# Initial special effect setup
regression_mypack_special_effect_targets = \
  testset_chartreuse \
  testset_bland \
regression_mypack_special_exec = mypack_special_exec
# copy for code coverage
regression_mypack_special_effect_ccov_targets = \
regression_mypack_special_back_color_iterations := 4

My problem was that I copied the variable name wrong. In line 8, I wanted to make a copy of the list of targets, with the names modified to be the ccov version of the targets. The difference is nearly invisible in the middle of the long variable name.

Verbose, clear variable names are an important part of self documenting code. Monotonous names with only underscore separators make that hard. Yet another reason to avoid “make” for complex projects.

Fun OGRE meeting!

There was a lot of activity at the OGRE meeting tonight, including knowledgeable questions and answers, and a great video setup in a meeting room at Jaded Pixel Technologies (Shopify).

John Duff demonstrated the Devise authentication framework with Facebook.

Jonathan Sutherland was persuaded to show off his Rails-based real estate agents’ web site.

Dwayne recorded much more detail than I have in a post to the OGRE mail list, including code links.

Test driven design in Bash

To test your bash scripts, or to use Bash to test other scripts, you need a way to create tests quickly and easily. I created a library to support testing in bash. I have used this library to test Bash, Python, and Perl scripts.

An updated version of the source code is available on GitHub.

Continue reading

Review: Ruby Tuesday – Feb 23 meeting

This is a monthly meeting of Ottawa Group of Ruby Enthusiasts’ (OGRE). This group attracts a broad range of presentations and attendees, resulting in a very interesting evening. Continue reading

Group Reviews

I have posted a list of Ottawa organizations that meet to discuss software-related topics. I have attended meetings of several of them  in the past and can recommend them. However, several I have not visited, so I can’t say what they are like.

Accordingly, I have decided to attend as many as I can in the next few months, and post a review here.

To be fair to all the groups, and to people who may have different goals in visiting a technical group, I will evaluate all the groups with the following criteria. They are very subjective criteria, so of course, ‘your mileage may vary.’ Continue reading

Splitting a perl program

Migrated. Originally posted: 2008-02-07

Like me, you have probably inherited a program or two that someone else wrote, and that could stand tweaking.

Any build system program needs updating as the system changes, with new demands, new technology, new builds. Perl programs can be structured to make this easy, or hard. I have a large program to tweak, and it’s all in one file – about 3500 lines long. 3500 lines is hard to work with in one file, so I am splitting it up. Continue reading