Infinite Bad Behaviors

Submitted by scott
punch card

It's time for the world of computer programming to prove it's usefulness by teaching us a thing or two about parenting.

There have been times when even I have written bad code. Sometimes my applications just keep crashing and don't want to do what I've told them to do. However, the real problem is (much to my dismay) that the application is doing exactly what I've told it to do. I've unintentionally gotten the application stuck in an infinite loop... no matter how many times I run it, if I don't change it's behavior, the application will just keep crashing, and spinning it's wheels. The same can be said about kids.

Below I have written some sample code, followed by an explanation.

behaviors = new Array("Eating Boogers", "Pushing Siblings", "Talking Back", "Eating Daddy's Fruit Snacks", "Screaming"); 

child_has_bad_behavior = true; 

 behavior_to_use = behaviors[Random()]; 

This example is fairly straightforward (I hope). First, there is a wonderful list of bad behaviors that the child has, or at least has the ability to acquire. This wouldn't be so bad, but on the next line we see that it is indeed true that the child has a bad behavior. So, what happens after the child develops this bad behavior? They begin to act out. This can be seen it what is called a while loop. In plain English, the last chunk of code says... while it's true that the child has a bad behavior, they will choose one of those behaviors at random to act out. On top of all that, in this case there is no action after 'ActOut' to curb the child's behavior. Therefore, nothing is stopping the child from acting out as many bad behaviors as their little heart desires.

How do you break the child's cycle of acting out? As soon as I fix my application kids, I'll let you know.

If you have questions, feel free to leave them in the comments. I tried to make the code as simple as I could, but I know things get easily lost in the translation.

   Share This Article

Add new comment