Saturday, June 28, 2008

a simple guide to static variables

I have been doing programming type stuff since middle school now (nine years, whoa) , with my first object-oriented experiences in high school Java class. I remember talking about static variables then (maybe in college too, I don't know). However, last Thursday I was writing some Actionscript code for my research project and realized I was mindlessly typing "public static var" in front of all my declarations, and that I really didn't know what "static" meant. So, I checked to see who was online, and my friend Lane was, and I asked him what static variables are. He explained it this way:

class Orange{
public var count;
public static var staticCount;

Orange(){
count++;
staticCount++;
}

}
...

var valencia = new Orange();
var navel = new Orange();

So, what will valencia.staticCount be? What will navel.staticCount be? What about valencia.count and navel.count?

Turns out that static variables are shared across all instances of a class. So, either of the staticCounts will be 2 after each instance is created (since each time the instance is created, the class increments staticCount), while each count will be 1, since the constructor also increments the non-static, unshared variable as well.

After I asked that question I figured out that a whole bunch of my program's bugs had to do with me declaring static variables where they should not be.

I don't know, it seems like several people I've talked to don't (or didn't) fully understand static variables either, but it's something really helpful to know.

Friday, June 20, 2008

i think this happens a lot

...wellll, except for the whole jumping out the window part, anyhow.


Planning ahead has its merit, but at the same time I think we miss a lot of opportunities in life
if we're letting our planned future get in the way of things that could be really good here and now. That's just my take on it.


(by the way, that's from http://www.xkcd.com)

Thursday, June 19, 2008

a bit of coding wisdom

"Everyone knows that debugging is twice as hard as writing a program in the first place. So if you're as clever as you can be when you write it, how will you ever debug it?"
-- Brian Kernighan

"Always code as if the person who ends up maintaining your code is a violent psychopath who knows where you live."

via http://www.codinghorror.com/

the demise of fish #2

Lynn (named after my academic advisor) died today, after Dr. McCrickard confessed at lunch to deriving enjoyment from giving his students sick fish to try to nurture and bring back to health, and after Stacy confessed to licking Larry previous to his death. Hahah.

The third fish is named Tiffany, after Dr. Tiffany Barnes. She's made out of construction paper. I think she'll live a bit longer than the other two.

Other than that, things are going great here. I'm a bit behind on my self-made project timeline, but it's all good, I'll still make deadlines.

Not much else beyond the typical is happening. I'm sure I'll post more later.

Wednesday, June 11, 2008

any summer internship where you end up having nerf gun wars/pillow fights/throwing things at your coworkers both in the lab and in the dorms has to be good.

i'm just sayin.

Sunday, June 8, 2008

miscellany

So, things are going well. Three weeks down at VT. I like my project, and I love the people I live and work with. We work hard, but we play hard too. We play volleyball almost every night and frisbee twice a week. I've learned how to do a cartwheel. I've had my hair completely done in braids. I've seen waterfalls and climbed trees and gone to the duck pond. It's been good.

On a sad note, Larry, my fish, died. He was sick. I was taking him to Petsmart, but he died before I could get him there. Sad day.

This weekend I'm home for my sister's graduation from high school. I'm so very proud of her. We did graduation this morning, and afterwards I got to see a bunch of people from the church I grew up in, which was good. A bunch of us went and saw The Strangers tonight. I laughed the whole way through it, but that's just what I do during cheesy scary movies

Tomorrow, I go to church and then head back to Virginia. For some bizarre reason I volunteered to watch the one-year-old nursery tomorrow during Sunday school. I suck at dealing with kids. I think that when Mom said that they needed help down there tomorrow I thought, hey, this is my opportunity to prove that I can totally take care of small children, despite common belief. So I told her I could help. She laughed at me. I took it as a challenge. I can so handle this.

Today I came to the conclusion that writing code soothes me. I think I take comfort in knowing that my carefully scripted lines will be interpreted in the same way time after time after time and that they won't change by themselves. I'm in control of my code. Nothing else has the power to change it. If there's something wrong, it's my fault, and it is within my power to fix it. I like that.

Does anyone else feel this way?

I think it's why I like housework sometimes too, especially when I'm nervous or upset. It is good to be able to put order into disorder, to make chaos livable.

I'm reading Zero: The Biography of a Dangerous Idea, and it's been talking a lot about how much resistance there was to zero or infinity existing. Early mathematicians had no notation for zero or infinity, and no representation of irrational numbers (numbers that can't be written as fractions), and in many sects suggesting the ideas of these things was tantamount to heresy. People were uncomfortable with the idea of void--it breaks a lot of properties that hold true for every other number. People were also uncomfortable with infinity, mostly because that's something we can't wrap our minds around. Yet zero and infinity are incredibly important concepts for higher level math. Calculus and physics are impossible without them.

To be honest, I'm afraid I'm a bit uncomfortable with infinity and void as well. Not in a numerical sense (I don't run away screamign from calculus textbooks!) but in a "I want my life to fit within these neat constraints" sense. Every day I learn that things are a lot bigger than I am and that there's a whole bunch that is out of my control. There's seemingly infinite time ahead of me and a void filling it. I have no firm plans. My life is different than I expected it to be, in the best of ways. It should be a comfort to me to know a sovereign God who brought all of creation into being even though it started in chaos, but unfortunately I am not as trusting as I should be. I wish to arrange these things myself...but I can't.

Sorry, guess this post was a bit disjointed. My thinking's disjointed right now too. It's time for sleep.

Saturday, May 31, 2008

fish

So yesterday Dr. McCrickard, my research mentor, walks into our little desk area, stares at a box full of fishtanks, and tells me to pick out an aquarium, put water in it, and one day he'll come in with fish. He put one on my teammate's desk too. Well...I got busy yesterday and didn't do it, not sure if he was serious, and thinking I had a couple days lead time if he was serious.

Fast forward to this morning. I woke up, spent time with God, went to breakfast, took a shower, got out of the shower at about 9:50. I turned on my computer and checked my e-mail...and there is a message from my mentor saying that he will be there this morning at 10:00 or 10:30 with the fish and that he trusts the aquariums are ready for them.

I threw on clothes, grabbed my bookbag and my makeup and ran to my car with wet hair and all, hahah. I got there just after 10:00, filled the aquariums, put on my makeup in the bathroom there, and got to work. Dr. McCrickard showed up at 10 :45 with the fish.

I strongly believe in showing responsibility in the small things :)

The policy is to name fish after former students. Apparently there was a former student named Larry, which is the same first name as Dr. Hodges, my research mentor at UNCC, so Dr. McCrickard felt that was an appropriate name for my goldfish. I told Dr. Hodges on Facebook. He said he would find a way to exact revenge. Hahah. I am terrified of this thing dying...

good night.