One thing that I have found writing software and testing it as I go is to structure an application in a way to make it easy to test. I find it much easier to do this when you separate any logic from where you persist data by saving it to a db or file or whatever. I always work best with examples, so let's use one: I need a class that will use complex (or not so complex) logic to create widgets and then save those to a db.
Here's one way to do it:
doEverythingMethod() {
for (loopCondition) {
// complex logic to decide what kind of widget to make
saveWidget();
}
}
Now, that's all well and good. However to test the logic of the method then you will end up making tons of widgets to the db. You might want to clean it up out of the db, but in the end you are making the test slow by saving things to the db when all you want to do is test the logic.
Here's another solution:
doEverythingMethod() {
collectionOfWidgets = complexLogicMethod();
for (eachWidget in collectionOfWidgets) {
saveWidget();
}
}
Collection complexLogicMethod() {
// complex logic to decide what kind of widget to make
return collectionOfWidgets;
}
The second way will allow you to test the complex logic in an isolated way. The doEverythingMethod() in the second example then needs less aggressive testing since it's simpler.
Short answer: slightly different structure of the application will make testing easier and faster.
Wednesday, 28 September 2005
Sunday, 25 September 2005
Podcast? Sold!
Okay, I know that I am behind the times. I am listening to my first podcast from cbc radio 3 and I am sold on it. No more annoying people from the local radio station playing the same crap every morning, just hearing new music that people think is cool. Awesome.
Oh, check out Litterbug on newmusiccanada.com for some songs that you can play. God, I hate Flash and RealPlayer sometimes... *sigh*
Update: The song was called "brush with life" from Litterbug that I liked. Listening to it again I'm not sure if I was just really tired and alone when I heard it first. I'll have to give it a try more. :-|
Oh, check out Litterbug on newmusiccanada.com for some songs that you can play. God, I hate Flash and RealPlayer sometimes... *sigh*
Update: The song was called "brush with life" from Litterbug that I liked. Listening to it again I'm not sure if I was just really tired and alone when I heard it first. I'll have to give it a try more. :-|
Labels:
tech
Friday, 23 September 2005
My precious
My birthday-present! It came to me on my birthday, my precious. So small, so beautiful... jimum! jimum!
Labels:
tech
Wednesday, 21 September 2005
Tuesday, 20 September 2005
Some nice stuff on flickr
Just poking around on flickr and some people have some really beautiful pictures. Man, I think that I have to dig around for some tips on how to take better pictures. That's next week's project. ;-)
Labels:
random thoughts
Running Log, LogDate 2005.09.20.1718
Dear running log:
It was a hard, windy run today. I was tilted sideways for a lot of it and I thought that I was going to get blown off a bridge as I crossed the Ottawa in my interprovincial run today. Gray, sunny, today had everything but rain. Same route for the last 3 business days, with time of 39:12, 40:14 (I blame the hot weather and traffic lights), and 37:28 today. I'd love to shave off a couple of more minutes, but I don't know how realistic that is right now.
Ideally I would just figure out how to use my watch correctly and keep track of my splits so that I can monitor progress. That'll be my project for next weekend. ;-P
It was a hard, windy run today. I was tilted sideways for a lot of it and I thought that I was going to get blown off a bridge as I crossed the Ottawa in my interprovincial run today. Gray, sunny, today had everything but rain. Same route for the last 3 business days, with time of 39:12, 40:14 (I blame the hot weather and traffic lights), and 37:28 today. I'd love to shave off a couple of more minutes, but I don't know how realistic that is right now.
Ideally I would just figure out how to use my watch correctly and keep track of my splits so that I can monitor progress. That'll be my project for next weekend. ;-P
Need practice
I've been trying to make coffee and take it in to work instead of always buying it. Some times I am successful, others not. Today I made coffee so weak that it's almost like tea... I think that I'll have to use a measuring cup to put the water in or get a one cup coffee marker filter thingy... ah well. ;-P
Labels:
home life
Monday, 19 September 2005
Sunday, 18 September 2005
Flickr account for us
I signed up for a flickr account this morning. It's flickr.com/photos/jim_and_laura/. Now I'm going to upload all our photos at this point. I might make some "hidden" because the quality (lighting, whatever) sucks, but other than that I think that I am going to put everything up. I'm always afraid of loosing that data if my computer crashes or the "worse" happens and my backups die.
It'll be easy to label, tag, and share the photos. I looked briefly into just getting hosting but the amount of hd space that I'd need would cost me 10x as much a year.
I can't upload all my pictures this month 'cause I have a 2 Gb upload limit, so I'll have to do more of the older stuff next month. I am going to try and work from the most recent backwards. I'll blog about how I like the service as I go along but I'm going to be using it for the next 2 years. ;-)
It'll be easy to label, tag, and share the photos. I looked briefly into just getting hosting but the amount of hd space that I'd need would cost me 10x as much a year.
I can't upload all my pictures this month 'cause I have a 2 Gb upload limit, so I'll have to do more of the older stuff next month. I am going to try and work from the most recent backwards. I'll blog about how I like the service as I go along but I'm going to be using it for the next 2 years. ;-)
Friday, 16 September 2005
Nasty vegetables
Nothing brings a happy moment to sudden stop quite like bitting into rotten food. In this case it was a carrot. Yuck.
Sunday, 11 September 2005
9/11
It's been 4 years. Wars are still going on, terror acts are still going on. We'll see what happens in the next 4 years.
More space on the network
One of the ideas that I had by putting my linux box on the network was to provide hard drive space for media like pictures and music. I have not turned it on in like 6 months. :-( Ideally I would just put on something like the Linksys NSLU2, but if I put my external drive on it the thing would never power down. I'd rather have something that powers down when it's not being accessed. So I have been looking at things like a Buffalo LinkStation but they are pretty pricey. I'll keep my eye out for something good though.
Labels:
home life
Friday, 9 September 2005
Music on the cheap
One of my co-workers pointed out allofmp3.com which is a site where you can cheaply get music in any format that you want. Very cheaply. Like less than 2 USD for an album. And rare stuff too that is very hard to find. I'm pretty excited about it 'cause I found a band that I love called Space where I have found it really hard to get the music.
Even though it's a Russian site and all that usually brings to mind, it (from what I was told) has won court cases that say they are able offer this service and everything is legal. I don't think that I'll give them my credit card though, I'll probably use PayPal when I do download stuff.
Yay cheap music. ;-)
Even though it's a Russian site and all that usually brings to mind, it (from what I was told) has won court cases that say they are able offer this service and everything is legal. I don't think that I'll give them my credit card though, I'll probably use PayPal when I do download stuff.
Yay cheap music. ;-)
Bodies...
Has anyone else noticed that for all the reporters asking people who have been to New Orleans they always get to a certain part of the interview where it goes like this:
"So, have you know, uhh, seen any bodies? Lots of them? Floating around? Gross eh? Did you, you know, poke them with a stick? Gross eh?
Now on to Bob for the weather..."
Okay, we get it. Lots of people died. There are bodies around, lots of them. We get it Media, we really do. You're starting to disgust me, not with thinking about bodies, but with you.
"So, have you know, uhh, seen any bodies? Lots of them? Floating around? Gross eh? Did you, you know, poke them with a stick? Gross eh?
Now on to Bob for the weather..."
Okay, we get it. Lots of people died. There are bodies around, lots of them. We get it Media, we really do. You're starting to disgust me, not with thinking about bodies, but with you.
Saturday, 3 September 2005
Ah crap...
We just moved from having Rogers to another ISP. I was afraid that I would loose the Yahoo! Photos and all the photos we have there. Well, we half lost it. My favourite thing about it was that I was able to upload the full sized photos and be able to download the same later. It was a great off site storage / backup for all the shots that I didn't want to loose. But with just a straight Yahoo! account I can no longer download them again. Crappy.
I have to figure out another good place to keep my photos for long term storage. *sigh*
I have to figure out another good place to keep my photos for long term storage. *sigh*
Labels:
tech
Friday, 2 September 2005
Scary...
After checking out a slashdot story I was really startled by what I read in that guys blog: "Crime is absolutely rampant: rapes, murders, rape-murder combinations." The looting was on the news.
The thing is I just don't get it, not at all. Are people really that messed up that a flood is all they need to revert to the lowest possible behaviour? I don't remember things like that when tsunami hit aisa. I don't remember any stories like that when the ice storm hit eastern ontario / western QC...
Is is just the Americans? Are they just freaking crazy? One person being interviewed on the news was saying how he didn't think that him looting was wrong, because if it was wrong the cops would be out shooting people for it. WTF???!!! Someone has to shoot you for you to figure out that something you are doing was wrong? Well, I guess people only make mistakes once then eh?
I am sure that there are "reasons" for how things have played out but it just blows my mind. I really hope that it's a few giving the whole situation a bad rap and there are tons of stories of selfless acts of kindness.
It's just that those don't make the news.
The thing is I just don't get it, not at all. Are people really that messed up that a flood is all they need to revert to the lowest possible behaviour? I don't remember things like that when tsunami hit aisa. I don't remember any stories like that when the ice storm hit eastern ontario / western QC...
Is is just the Americans? Are they just freaking crazy? One person being interviewed on the news was saying how he didn't think that him looting was wrong, because if it was wrong the cops would be out shooting people for it. WTF???!!! Someone has to shoot you for you to figure out that something you are doing was wrong? Well, I guess people only make mistakes once then eh?
I am sure that there are "reasons" for how things have played out but it just blows my mind. I really hope that it's a few giving the whole situation a bad rap and there are tons of stories of selfless acts of kindness.
It's just that those don't make the news.
Labels:
interesting read
Subscribe to:
Posts (Atom)