Showing posts with label programming. Show all posts
Showing posts with label programming. Show all posts

Friday, July 15, 2011

Acknowledging Flaws

"The first step to solving any problem is to accurately define the problem."

My dad told me those words of wisdom several years ago when explaining the correct way to troubleshoot a computer bug. I think I was eight at the time.

"You wouldn't believe how many people call our office, only to say 'well, my computer isn't working'. That's not helpful. There are countless ways a computer can 'stop working', and often it's actually an error on the user's behalf. Half of the time, the client simply forgot to click the OK button. Unless the client tells us exactly what the problem is: "clicked/typed such and such, expected certain response, but computer responded in such and such a manner that was undesirable", it is nearly impossible for us to tell them how to fix their 'bug'."

Those words have stuck with me through the years, and since then, technical difficulties have been considerably less frustrating. However, I don't think this wisdom applies only to the realm of computers.

In order to solve any problem in life, it's important that you first define exactly what the problem is, and (if possible) how the problem arose.

This is why in therapy groups, each of the members introduce themselves along with their problem. "Hi, my name is [insert here], and I've been an alcoholic/drug abuser/mentally ill/etc. for the past [insert time frame here]."

The simple act of acknowledging a problem is an essential part of the recovery process. However, as with many things in life, that's easier said than done. For some people (ahem: me), self-imposed ignorance is a critical coping mechanism. Whether this is out of an unhealthy desire for perfection, or fear that there is no solution, or simply sheer pride, I'm not sure.

The fact of the matter is that this kind of thinking is terribly skewed. For one thing, the idea of perfection in humans (at least, while on earth) is laughable. We all fall miserably short. However, there is hope for some improvement... if we know what we're dealing with. Acknowledging our flaws enables us to adress them, counterbalance them-- or at the very least, strips them of some of their power by naming a nameless beast. Even if there isn't anything that can be done about it (and there almost always is), having an identified problem is often much less overwhelming than dealing with generalized failure. Too often we equate 'sometimes failing' to 'being failures'.

As for pride... Well, that's a whole topic in itself.

In short: It's not necessarily wrong to have problems, but it's what we do with them that counts.

Friday, February 18, 2011

I Heart Algebra

Ahh. It's my first day back in dear, sweet Algebra, and I've already realized why I missed it so much. Unlike geometry, it's practical. Sure, I can see where geometry would be useful to a surveyor, architect, pool player, or some other such geometrically-inclined professional, but Algebra is actually applicable to me, now.

For instance, take this supposedly illogical math problem:

x = x + 1

Wait just a second! you say. At first glance, this problem looks impossible. It doesn't take a math whiz to realize that any number plus one will no longer equal itself. Oh, but wait. Herein lies the beauty of math.

To demonstrate the problem in its application, let's pretend we are going to create a simple text-based computer game using visual basic. To beat the game, you have to answer three questions correctly in a row. "X" is defined as the number of correctly answered questions. At the beginning of the game, the player has zero correct answers.

x = 0

The player launches the game, and he or she is presented with one of various pre-defined randomly selected questions. In this example, the first question is "What is the capital of Djibouti?" The correct answer is Djibouti. The code for this particular question would look something like this:

answer = inputbox("What is the capital of Djibouti?")
       if answer = "Djibouti" then
       AddScore()
             else
       Reset()

If the answer is anything other than "Djibouti" (aka if the answer is wrong), the player is sent to the function Reset(). In this case, Reset() consists of little more than x = 0. This (gasp!) resets the player's score to 0, no matter what. Reset() then sends the player back to the questionaire function.

If the answer is correct, the player is sent to AddScore(), which contains that tricky little math problem we discussed at the beginning of this post.

x = x + 1

This is read as "the value of x is equal to the previous value of x plus one". Remember, x was set to 0 at the launch of the game. The script will therefore interpret the problem as follows:

x = 0 + 1 (or) x = 1

In our game, AddScore() also checks if three questions have been correctly answered in a row.

if x = 3 then
       WinGame()
             else
       Questionaire()

If the number of correctly answered questions is equal to three, a congratulating message will appear. If not, the game loops back to the question function. In our case, the value of x is only equal to one, so we must ask the player more questions.

Pretend the player answers the next question correctly. The code in function AddScore() still reads x = x + 1, but now the program interprets it as:

x = 1 + 1 (or) x = 2

Because x does not equal three, the function loops back to Questionaire() and asks another question. If the player answers the next question incorrectly, x resets to 0 and he or she must start from scratch. In this case, we'll pretend that the player has answered their third question correctly. x = x + 1 is now interpreted as:

x = 2 + 1 (or) x = 3

X is now equal to three, so the player wins! This is a rough example of how an algebraic problem can be applied in a computer program, but you get the general idea.

Yes, I know what you're thinking. I'm a total, complete dork. I won't deny that. And I won't stop loving Algebra. <3