def … end

I have been through a number of different, mostly lower level, computer programming classes. At this point through school I have done C++ and Java, which if I was more skilled or had the degree or had defined job experience (at least one of the three) could result in a decent job that kept my husband in bacon and me in chocolate.

At the University of Kentucky, they start new students in Python. Now, I was grandfathered out of taking that class because, well, Java. Nothing wrong with that. So, instead I took the Python course in Codecademy. Now, I’m under no illusion that using Codecademy is going to net me a job involving creative problem solving with computer programming. It does, however, allow me to become familiar with different types of programming languages, different database tools, and different programming tools (yeah, I’m looking at you Git).

All told, last year I completed 11 skills. Not too bad for an aging 40-something, full time worker, part time student, parent, volunteer, what have you.

It’s a great tool, and like doing the crossword puzzle on Sundays, it helps keep my brain sharp. Sadly, I don’t get to use most of what I’ve learned on a daily basis. Other than going in and working towards a new skill (Ruby at almost 50% completion), what do other people suggest for making programming more a part of daily life when it isn’t part of your work life?

The Problem Statement

Like my experience in Japanese, programming languages benefit from practice. My last problem statement was to implement a text editor using a linked list. Welcome to practice with pointers.

The problem statement included this information:

If the letter I is entered with a number n following it, display a prompt along with the line number n, after user types a line of text, then insert the text at line n, and the original text at line n becomes line n+1. If n is larger than the total number of the current lines displayed from the editor, then you need insert a few lines of empty text in order to insert the user input text at line n.

Now, don’t ask me how I managed to flub a simple reading assignment, but I took this to mean that I needed to implement two different style insert functions where the base case was that someone just typed a line and pressed enter and the text should be inserted at the end. The second case was the case listed above: the user entered I and a line number and the text was inserted at an appropriate spot in the code. It is here where more practice would have helped.

I implemented this by prompting the user to select their command, which then initiated the subroutine (so press I and enter and get prompted for a line number). It took until a lab session about 2 weeks ago when I realized that I could have just tested the string and not forced my users to be quite so explicit. It means more error handling for me possibly, but a better experience for the user.

So, I’ll be rewriting the code sometime this week to change how I’m implementing my solution. Anyone else have an aha moment that results in rewriting the entire program?

Should I do the rewrite before or after I do the test cases?