Archive for category Software, Technology, and Computing

Blog is Shutting Down

This blog will be shutting down soon.

For readers of the Bain Report, please go to bainreport.wordpress.com.

For readers of any technical content, please go to artofsoftware.org.

The Week in Review has been discontinued entirely.

Thanks for reading!

Leave a comment

A Game Theoretic Analysis of Dropped Cell Phone Calls

A problem that I suspect all cell phone users have goes something like this:

  • Alice calls Bob.
  • Alice and Bob get to talking and are having a productive and interesting conversation.
  • One of their phones drops the call.
  • Both Alice and Bob attempt to call the other, but each are directed to the other’s voice mail.
  • Both Alice and Bob try again with similar results.
  • Eventually, and after some frustration, they reconnect.
  • The conversation resumes, but not before the obligatory “my cell phone always drops calls in this part of town” conversation has occurred.

It turns out that we can use game theory to describe this situation.

The normal form game below describes what happens after the call is dropped, and allows both Alice and Bob to take one of two actions – call back or wait.

call back wait
call back (0,0) (1,1)
wait (1,1) (0,0)

This game is both symmetric and non-zero sum, and is commonly called a coordination game.

A common coordination game, which is isomorphic to this situation, is the case where two people are driving toward each other on a road and must decide on which side to drive. Either side is equally preferred by both as long as both choose the same – either left or right. Moreover, both sides are interested in preventing a head-on collision, so both are interested in making the correct choice.

In these types of situations it is common to settle upon some conventions, which are sometimes codified into law and sometimes not. The conventions allow us to coordinate our behavior and help us to avert unwanted outcomes.

As far as I know no convention about who should call back and who should wait has been adopted for when a cell phone call is dropped. Many different conventions would suffice. For instance, the person whose first name was alphabetically before the other’s name could call back. Or we could use last names. The ways to settle this are innumerable, but I would like to suggest one that I think makes sense.

The person who initiated the call to begin with is responsible for calling back. So, given our example where Alice originally called Bob and the call dropped, Alice will call back and Bob will wait. That’s it.

References: Leyton-Brown, Keven and Yoav Shoham. Essentials of Game Theory: A Concise, Multidisciplinary Introduction. Morgan and Claypool, 2008.

1 Comment

Software Defect Snowballs

Sitting there at our desks in the morning staring at the list of defects confronting us can be overwhelming.

Scanning through them, we often come to realize that the highest priority defects will be both tricky and time consuming to fix. We realize that most of our day will be spent on just a small number of them, which means that our list will be nearly as big tomorrow as it was today. And of course, depending upon tester activity, we could end the day with a much longer list than which we began.

Like in the Red Queen’s Race, we run as hard as we can and end our day no closer to finishing.

The situation can be improved.

Dave Ramesey, a popular financial advisor who helps people get out of debt, suggests using the debt snowball approach for overcoming debt. The essence of this strategy is to pay off all of our debts by beginning with the smallest one first, and then progressively working our way toward the largest. By taking this approach we build the will and the psychological momentum needed to help us payoff our biggest debts

We can apply this strategy to fixing software defects.

The obvious way to apply this strategy is literally, and it does not work. That is, no one is going to be happy if we just re-prioritize our entire list so that the easiest to fix defects have the highest priority.

So what we will do instead is partially re-prioritize our list in order to “prime the pump”. That is, by picking one or two quick-to-fix defects at the beginning of our day, or even in the middle of the day between big jobs, and then fixing them immediately, we generate some momentum for taking on our bigger challenges.

In addition, I have found that those who reported the lesser priority, but easily fixable defects are always happy to see their issues resolved sooner than expected. What’s more, individuals who are waiting on the large problems to be fixed are typically not bothered by the relatively minor digression. So on top of helping us be more productive, this technique also engenders good will amongst our colleagues.

Another effect of this “defect snowball” method is that the application of it helps to keep our defect queue clear of small problems, and thus prevents them from adding up and becoming a big problem later.

Now of course some care must be taken when choosing the “easy” defects to fix. To avoid jumping head first into an unexpected big problem, we really want to limit ourselves to choosing ones that are obviously low effort. Defects that are almost always low effort are the ones associated with the quality of error messages or misspellings. Sometimes we can also find “quick fix” defects that are in the same software element as one of our big defects, and which if attacked together saves us a context shift.

However, regardless of the particulars, sound judgement and knowledge of the details on the ground are definitely required. Developing an intuition about when to abandon something previously thought “easy” is also a good skill to hone.

1 Comment

Remote Desktop Lockup/Freeze on Login

A couple days ago (mid-November 2009) there was an update from Microsoft. After applying this update I was unable to remote desktop to the machine to which the update was applied.

Actually I was able start the remote desktop session, but after typing in my login and password the remote desktop session would freeze. Not only that, but the machine that I was making the connection to froze-up as well. It wasn’t even responsive to a three finger salute at the console. Hard reset was the only way to restart it.

I searched around trying to figure out what the problem was. Later I talked to a friend of mine, also the sys-admin where I work and he was able to help me.

Since the solution to this was hard to find I thought I’d post it. Note that there was nothing in the event log to suggest what the problem was.

Anyway, we edited a registry key in:

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management]

and added:

“SessionImageSize”=dword:00000020

Note, this is in HEX and corresponds to 32MB.

After applying this I was able to connect to the machine via remote desktop again. I’m not sure WHY this worked, but it did. That’s good enough for me right now for this problem.

For what it’s worth this fix also appears to work when the system is unable to load rdpdd.dll. My friend had that problem on another machine.

1 Comment

Bash function for ‘cd’ aliases

For about two weeks there I thought I was going to drop Cygwin for Windows Power Shell. As I was in the process of doing that I ran across an interesting WPSH function by Peter Provost. Nothing earth shattering, but it was pretty useful. Keep a map of aliases to full paths and provide a function “go” that changes your current directory to the full path when you invoke “go” with the appropriate alias.

I got used to using this in WPSH and decided that I would implement it in bash. Of note: I had a number of aliases and shell functions defined before that did this, but using the map, or in the case of bash a file, to hold the aliases makes the whole scheme a heck of a lot more extensible.

Anyway here it is:

##############################################
# GO
#
# Inspired by some Windows Power Shell code
# from Peter Provost (peterprovost.org)
#
# Here are some examples entries:
# work:${WORK_DIR}
# source:${SOURCE_DIR}
# dev:/c/dev
# object:${USER_OBJECT_DIR}
# debug:${USER_OBJECT_DIR}/debug
###############################################
export GO_FILE=~/.go_locations
function go
{
   if [ -z "$GO_FILE" ]
   then
      echo "The variable GO_FILE is not set."
      return
   fi

   if [ ! -e "$GO_FILE" ]
   then
      echo "The 'go file': '$GO_FILE' does not exist."
      return
   fi

   dest=""
   oldIFS=${IFS}
   IFS=$'\n'
   for entry in `cat ${GO_FILE}`
   do
      if [ "$1" = ${entry%%:*} ]
      then
         #echo $entry
         dest=${entry##*:}
         break
      fi
   done

   if [ -n "$dest" ]
   then
      # Expand variables in the go file.
      #echo $dest
      cd `eval echo $dest`
   else
      echo "Invalid location, valid locations are:"
      cat $GO_FILE
   fi
   export IFS=${oldIFS}
}

Leave a comment

Running Python Scripts Inside Windows Power Shell

I took a big leap and decided that I was going to trade in cygwin for Windows Power Shell. Well, at least that’s the theory. We’ll see how it actually goes in the long run.

Anyway, I have quite a few python scripts that I was using, which I can pretty easily port to native Windows Python. But of course I want to be able to run them inside of WPSH.

Assuming a script named “tst.py” in the current working directory, I tried a variety of things to make this happen:

  • Just type in the name of the file “./tst.py”. This zapped up a new command window and ran the python script in it. This is not very useful because I really need to see the output. (Note: If you do this inside of a command shell the behavior is correct.)
  • Rename the file from “tst.py” to “tst.pyw” so that pythonw.exe will be used to run it. Also a no go. I got no new command window, but also no stdout to the WPSH.

Those were the obvious things to try. So I began to search, and found references to IronPython and how to run it inside of WPSH. That and a variety of other things, but nothing that solved my actual problem. (i.e. got my current python scripts to run correctly in WPSH).

Now, if I run python itself from WPSH I get a python prompt from where I can do python stuff. So I tried typing “python tst.py” in WPSH and viola I saw my output.

Since that worked I went ahead and defined the following:

function tst { python tst.py $args}

Given that I have a new WPSH function that calls python on the file “tst.py” and passed through the args. This has the behavior I was looking for. The big downsize here is that I have to write a WPSH wrapper function for each of my python scripts, but I have only about a dozen so that’s what I’m going to do. I am not 100% satisfied with the soluton, but it’s good enough for now.

Update:

I found a better way to do this here. Essentially put:

@setlocal enableextensions & python -x "%~f0" %* & goto :EOF

At the top of your script.

Here’s a full example, the file is named cg.cmd.

@setlocal enableextensions & python -x "%~f0" %* & goto :EOF

from devtools.codegen.api import cg_main

if __name__ == "__main__":
   cg_main()

 

Leave a comment

Deriving from PyQt4.QtCore.QObject

I was trying to connect the signal of an object I had derived from QObject to the slot of a QWidget. It turns out that if you do not call the QObject.__init__ method in your Python object’s __init__ function that you will get a, “RuntimeError: underlying C/C++ object has been deleted”, exception. It took me a bit of time to figure this out, and since the PyQt documention is sometimes lacking I thought I’d share.

Leave a comment

Follow

Get every new post delivered to your Inbox.