I wanted to delete the boolean variable x because it didn’t seem to have any effect on the program. Everywhere the getX() function was used, it was always of the form:

if (getX()) return;

But when I searched all instances of setX(), it was always set to false. The variable x is also a member of class A and A’s constructor likewise sets x to false. The only remaining code that sets x, then, is A’s member function setMemberVariables() which takes in arguments to set all of A’s member variables, not just x.

When I searched setMemberVariables(), however, I found that several different classes have a function with the same name. The only differences were the parameters. Using the the ever-handy SurfFind, I searched the whole project for instances of this function and it returned over 700 results!

Luckily, A’s setMemberVariables() function was the only one that took 12 arguments. The others had more or less but none of them had exactly 12. So all I had to do was go through all 700+ results and count if they have 12 arguments.

It took a while but I finally finished and found out that A’s setMemberVariables() function was not being called anywhere at all. Now I could delete the variable x and its corresponding getter and setter methods without fear.

After deleting them, I compiled the project in order to commit the changes right after.

Here I realized my stupidity, inefficiency, and single-mindedness. In order to find out whether A’s setMemberVariables() function was being used, I could have just easily renamed the function to some name I am sure is not used in the project like “asdfghjkl” and tried to compile!

I tried this method just to be sure. Fortunately, my manual checking was correct and the project did in fact compile without problems.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Create a free website or blog at WordPress.com.

Up ↑

%d bloggers like this: