Contents ----- Copyright Previous Next

Use-Case 3: The Great Renaming

For a change, now for a less destructive usage:

The most common reason why you want to do The Great Renaming is that the names for functions, records and variables in your program ended up in an inconsistent mess. There might be a read_cfg, a conf_write and a UseConfig. Wouldn't it be nicer if there were a config_read, config_write and config_use?

(If you now think it would not, you can skip this chapter and go on writing crappy code.)

Also, sometimes on is forced to work in a source code some fossil Unix-jerk has produced. That means, the above mentioned functions would be named something like rdcfg, wrcfg and cfgdo. For sure nobody will able to pronounce them.

Usually renaming all occurrences of these functions can be a quite awful lot of work, especially for low-level functions that are called from several modules.

With Vahunz, it is a matter of two minutes:

First, create a file list and choose (or also create) a proper dignorary as described in the previous use-cases, and create the dictionary by invoking Vahunz.

After that, load the dictionary, and search for the lines containing the functions you want to rename. In our example, they would look like:
 read_cfg
 conf_write
 UseConfig
Now change them to
 read_cfg=config_read
 conf_write=config_write
 UseConfig=config_use
Take care that the blank in the first column is preserved, and that there are no blanks or tabs around the equal sign (=). After that, start Vahunz, telling it to preserve comments and indention:
vahunz --comment --indent
The output should look as the input, except that the three names from before are now more consistent and meaningful.