Home
Downloads
Pictures
Links
Points of Interest
Your Site Sucks!
Your Site Rules!
Polls
Login
Overwhelmed
August 21, 2005
I'm going to clean my room today. It's not like there's food and wrappers and dirty plates all over the place, but there is a lot of computer stuff lying around, and soda cans. But, I look around and I'm like "F#@%#$@!!!" That's all I can mutter. But, then I just remember the definition of recursion
an expression such that each term is generated by repeating a particular mathematical operation
So, WTF in the WORLD does that have to do with cleaning my room? Simple. Well, let me break it down into a function.
int removeItem(Item[] items){
if (items.size() == 0) return 0;
items[items.size()-1].remove();
return removeItem(items);
}
As you can see, it's all about performing the same action, over and over again, but with a twist. Recursive functions call themselves. It's a very neat way to think when you're writing a program, and once you start to "think recursively", which I have to admit took me a few months in school, then you start to always think recursively, which is why I post this entry. So let's look at the program.
public void cleanRoom(){
Item[] items = ;/// get items from "Room" database
removeItem(items);
}
So, calling removeItem once will clean your entire room. Of course you could just have a "for loop":
for (int i = 0; i < items.size(); i++){
items[i].remove();
}
This gets into asynchronous access issues, array indexing issues, and everything that I just don't want to have to deal with when cleaning my room. You would have to reverse the loop, from items.size() to 0, and it's just too much thinking for something that shouldn't take much thinking at all. Grab item, throw it in trash bag. That's it. I'm not thinking any more than that. Thinking's stupid.
Thinking this way helps me to not feel overwhelmed. It's just one action, repeated over and over again, until the room is clean. And, the room will be clean when I cannot repeat the action any further, when there are no more items. Or when I'm passed out on my bed under a pile of computer game and parts boxes, and shoeboxes, coincidentally. That helps me as well as putting on my favorite tunes from Jimi Hendrix and Cracker. This is going to rule.
Hopefully you've learned a bit about recursion and computer programming, and how someone can think about this stuff all the time, except when they're trashed. Get it, trashed?! I kill me.
Comments
Your Name
Email or Website (optional)
Your Comment
Remember my info
July 2010
Sun
Mon
Tues
Wed
Thu
Fri
Sat
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
June 2010
Sun
Mon
Tues
Wed
Thu
Fri
Sat
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
Browse By Month
April 2009
(1)
October 2008
(2)
September 2008
(1)
August 2008
(1)
July 2008
(4)
June 2008
(6)
May 2008
(9)
April 2008
(8)
March 2008
(11)
February 2008
(12)
January 2008
(6)
December 2007
(6)
November 2007
(3)
October 2007
(6)
September 2007
(5)
August 2007
(4)
July 2007
(6)
June 2007
(1)
May 2007
(2)
April 2007
(11)
March 2007
(5)
February 2007
(12)
January 2007
(7)
December 2006
(12)
November 2006
(12)
October 2006
(14)
September 2006
(6)
August 2006
(7)
July 2006
(12)
June 2006
(20)
May 2006
(16)
April 2006
(11)
March 2006
(19)
February 2006
(13)
January 2006
(15)
December 2005
(14)
November 2005
(17)
October 2005
(19)
September 2005
(20)
August 2005
(32)
July 2005
(21)
June 2005
(37)
May 2005
(38)
April 2005
(12)