Thursday, October 28, 2004

28 October 2004

Gracie completed her first term of pre-school this week. We'll register her for the next term (begins next week). She's such a big girl. Jeff Shipley (our home teacher) came over last night and read us a book by Max Lucado called, "You are Special". Gracie sat right next to him, and was quite engrossed. It's really a nice book.

There was a full lunar eclipse last night -- Erin and I observed the last few minutes of it.

Monday, October 25, 2004

October 25, 2004

Had lunch with Richard Reukema, Mike & Tyler Gedlaman today. Just before lunch, Dad sent me an message with some photos of Matthew. He's actually quite pleasant, now that he's starting to come out of his screaming phase.

Judy Taylor and her mother (Cathy's sister) Joanne are in town for the next ten days. We all had dinner at the Melchin's last evening. I had been out home teaching, so I arrived a bit late. We had a rousing discussion about the upcoming U.S. election between George Bush and John Kerry. Most of the discussion was centered around the candidates position on the various issues. We had lots of talk on abortion, stem cell research, foreign policy relating to the war in Iraq. I quite enjoy having a couple of bona fide U.S. residents in town to debate the issues with. I have a tendancy to get pretty involved/passionate in these sorts of discussions - Judy whacked me once or twice.

On a somewhat related note, Ralph Klien called a provincial election today (set for November 22). Won't be much of a race, the Conservative party is pretty strong.

Saturday, October 23, 2004

Halloween Party / Pumking Giveaway

I took Gracie to the annual pumpkin giveaway this morning (hosted by a Tuscany real estate agent). We've done this for the last three years (at least). This year was different though inasmuch as there was quite a bit of snow. Gracie wanted to pick out a small pumpkin this year, she kept saying that she wanted to carve a "small mouth" into it.

Erin and I went to the ward Halloween party last night, held at Pat and Brian Morrison's place (they have a beautiful house). The party was well attended and a lot of fun. Erin and I went as Little Red Riding Hood and the Big Bad Wolfe. Sean and Lara went as vampires, complete with veneer fangs. CJ and Jessica Burton went as Yoda and Pricess Lea (CJ was painted green, had the pointy ears, bald head everything...). Sean Haslam came as a cheesy 70's police officer -- his moustace was brilliant. Kelly McTighe won the best male costume for coming as an LDS missionary. Richard Young performed a little magic show.

Thursday, October 21, 2004

We've had the first few real days of snow this week. Kind of dissapioting. I used to love the winter (in high school) -- lots of skiing etc... but now the winter just seems cold. I have been out for my first few turns on skates -- which has been fun.

I'm Working late tonight, there's got lot's going on at work. Today, the CEO of the Calgary Health Region announced that it would be authorizing 250 extended-stay surgical procedures to be performed at HRC. It's been a really big deal here at the office ... we've been waiting for this for the past seven years.

Most of the guys have been spending a considerable amount of time at HRC. Approximately 30 - 40 % of my time has been devoted to working at, or on HRC related projects. The first floor development is coming along nicely. We'll be getting ready to pull the voice and data wire in the next week or so (I've got Mike Gedlaman helping with that).

Erin is off tonight at the cannery doing some "dry-pack" -ing. Lara is watching the kids until I get home. Erin has done a good job as the Relief Society food storage specialist.

We had a terrible time getting Gracie to bed last night. She was so tired, but couldn't sleep. Erin turned on a wind-up music box to distract her, which eventually proved to be trouble. Each time the wind up toy ended, Gracie would wake up and cry out. She didn't fall asleep until I hooked up an MP3 player to some computer speakers and put some music on for her. Erin went and bought a small CD player for her; hopefull bedtime won't be so tough tonight.

Matthew on the other hand, reaches out for his crib when we put him to bed. He goes down gleefully. He's been really easy lately, mostly because he's started to communicate over the past few weeks. He has a vocabulary of about five or six words, and three or four hand gestures. Erin and I have been amazed at what a different child he's been since being able to communicate with us -- even in a small way. As it turns out, he's actually kind of loveable when he's not screaming.

Thursday, October 14, 2004

Update Parent-Child Data with an Identity Column

This article describes how to update parent-child data from a dataset. http://support.microsoft.com/default.aspx?scid=kb;%5BLN%5D;320301&product=vcSnet

Blog Application Progress

I've made some decent progress on my blog application. I've simplified the entry dataset (which is really the heart of the application) and re-wrote all the stored procedures with better joins and no temporary tables. This way I get much better resultsets that allow me to write much less procedural logic in the application layer.

I've also written a custom user control for displaying data to the page. The control is called DisplayEntry.ascx and it has a single property of type Entry_DS (a dataset) named resultset. Resultset simply receives the entry result set as requested by the application and formats it. This is nice because it basically turns my whole blog application into about three pages: an admin page, a posting page and a display page. And it does all this without compromising flexibility.

I'm hoping to have version one the application working sometime next week -- but computer time is a rare, precious gift -- so I'm not sure when V1 will go up.

Sunday, October 10, 2004

Sunday Night Political Discussion Topic: U.S. Electoral College

Went over to mom and dad's place tonight (as we normally do on a Sunday evening) for dinner. Dinner was nice -- always is.

After dinner Kevin and I chatted about computers, programing, "A Short History of Nearly Everyting" (a book I'm reading that Kev and dad have already read), and dad joined for the political discussion.

I made reference to the U.S. electoral college system, and remarked that Americans don't actually vote for the president, but rather that they vote for electors who elect the president. By this time Kevin was asleep on the couch (I suspect he wasn't actually asleep, but that he was disinterested enough in the conversation that mock-sleeping was a better alternative. Dad questioned me on the electoral college system, and I didn't have a strong enough knowelge of the convention/electoral college system to speak authoritatively on it -- but I was quite sure of the generalities.

Here's a quote from the U.S. Federal Election Commision's website:

"On the Tuesday following the first Monday of November in years divisible by
four, the people in each State cast their ballots for the party slate of
Electors representing their choice for president and vice president (although as
a matter of practice, general election ballots normally say "Electors for" each
set of candidates rather than list the individual Electors on each slate)."


Here's another, more clear explanation from infoplease.com:

"In the November election, the voters cast their votes for electors, not for
president. In some states, the ballots include only the names of the
presidential and vice-presidential candidates; in others, they include only
names of the electors...

"On the first Monday after the second Wednesday in December, the electors cast their votes in their respective state capitols. Constitutionally they may vote for someone other than the party candidate but usually they do not since they are pledged to one party and its candidate on the ballot...

"The votes of the electors, certified by the states, are sent to Congress, where the president of the Senate opens the certificates and has them counted in the presence of both houses on Jan. 6. The new president is inaugurated at noon on Jan. 20."

So there you have it. A little refresher on the American electoral college. By the way, the electors are chosen from state delegates at the parties national convention in the summer before the November election. And, though highly unlikely, it is technically possible, and more importantly it's legal for the electors to cast thier ballot for someone other than the candidate they're pledged to vote for. Now that's odd if you ask me.



Coding Guideliness

I've always been interested in coding practices and standards -- which is why I like the concept of design patterns so much.

I came across this coding guideliness whitepaper while trying to learn how to query a DataSet (more than just setting the rowFilter property equal to some expression). I never did find out how to query a DataSet.

Thursday, October 07, 2004

FarenHYPE 9/11

I'm glad somebody has finally put together a rebut of Micheal Moore's Farenheit 9/11 -- I just hope they do it right. (The very mention of Moore's name gets me worked up.) I watched the trailer, and unfortunately I wasn't overly impressed -- looks like they've got the same three people slamming Moore, and praising Bush... too bad.

I hope I'm wrong. Frankly, I think Farenheit 9/11 is an exceedingly manipulative film, targeted to the little-educated, mid-western undecided American voter. I think many viewers of the film will not have thought critically about Moore's tactics, and the formulation and subsequent presentation of his argument. If you ask me he's really only got one arrow in his quiver: shock value -- on which he relied too heavily, and I think it got him into trouble (ie: he tried to make out as if he was uncovering a smoking gun almost every ten minutes in the film, hoping that viewers would be stunned by the revelation, and wouldn't think about it for themselves). He took a lot of short cuts-- connected some dots that can't be connected. Cheap.

Farenheith 9/11 begs a rebut; someone should produce something that holds Moore accountable for his assertions.

I could go on.. but it's late. I'm off to bed.

Recursion Alternative; or Non-Recursive Recursion Part II

I'm posting the code to my non-recursive recursion sample. I've made one minor stylistic change, by using a "while loop" instead of a "for loop". This example gets all decendant categories of a multi-generation category tree. It returns an ArrayList of int's. I've taken this directly from the blog application I'm working on, so there's some irrelevant (to this example) code -- you'll have to ignore it.

I'm also using this post as a test of the very cool C# code formatting tool written by Jean-Claude Manoli. The formatting tool and the C# project code can be found here. To view the code more easily, copy it out of the scrolling widget below, and paste it into VS.NET.



public ArrayList GetAllDecendantCategories(int category_ID)
{
//initialize the counter
int i = 0;

// read the datasource property from the app.config file
this.appSettingsReader = new AppSettingsReader();
string connectionString = (string)appSettingsReader.GetValue("datasource", typeof(string));

//create an ArrayList to hold the category_ID's
ArrayList ar = new ArrayList();

//add the parent category ID
ar.Add(category_ID);

//opent the connection to the database
SqlConnection Connection = new SqlConnection(connectionString);

while (i < class="rem">//database logic...
string commandtext = "SELECT category_ID FROM Category WHERE category_parent = " + ar[i];
SqlCommand command = new SqlCommand(commandtext, Connection);
SqlDataAdapter adapter = new SqlDataAdapter(command);

//create a datatable to hold the categories
DataTable dt = new DataTable("category");

//clear and fill the categories DataTable
try
{
dt.Clear();
adapter.Fill(dt);
}
catch (Exception ex)
{
string message = ex.Message;
}

//loop over the resultset and add the child elements to the ArrayList
foreach (DataRow dr in dt.Rows)
{
//make sure the parent element is not being added as a child element
if (Convert.ToInt32(ar[i]) != Convert.ToInt32(dr["category_ID"]))
{
ar.Add(dr["category_id"]);
}
}

//increment the counter
i++;
}
return ar;
}

Set Vs. Procedural Logic

I learned something cool today... something that I actually thought I knew before, but when a more difficult application of it presented, I found out that I didn't understand it as well as I thought.

Set logic!

Note to self: whenever a very data centric problem presents, always consider the a set logic solution before a procedural solution.


Richard keeps drilling this into my head -- but today, magically, a small iota actually registered in my brain, and perhaps found a permanent resting place. Set logic is not the traditional way to solve data-centric application problems. "Most developers", as Rich would say, "will consider a procedural approach first." Our brain is accustomed to solving problems as a series of steps, not as chunks, or groups.

For instance, how would you count the number of people in a hospital bed at a give period of time. Most developers (myself included) would do some variation of the following: Find out what time it is, loop over the beds and determine if there is a patient there -- count it if there is a patient ther, don't count it if there isn't. This is a procedure, therfore procedural logic is used to solve the problem.

The alternative... is going to have to wait until tomorrow.

I'm tired (having worked until almost 1:00 AM developing a set logic solution to the hospital bed count probem.

Tuesday, October 05, 2004

Happy Birthday Sean!

I worked late this evening and totaly forgot it was Sean's birthday today. They all had dinner without me. Turned out to not be such a big deal given that Sean was completely consumed with building his rock wall/garden/water feature.

I learned some pretty cool SQL stuff today -- I still don't completely understand it, but Richard showed me some very crazy joins. I'll post more when I understand it better. I also wrote a SQL user function that takes a coma separated list of values as a parameter to stored procedure and turns it into a table of integers that can be used as the IN condition of a WHERE clause -- more on this later too.

Monday, October 04, 2004

Baby "Chou Chou"

I was overcome today by a doll.

Over the lunch hour I found myself at Toys R Us staring a "Baby Chou Chou" right in the price tag. I succumed and bought it for Gracie (she's been desperate to play with Sommers Chou Chou doll for the last few weeks).

When I came home and gave her the doll, Gracie was ecstatic. I confess I was excited to bring it home to her too-- I knew she'd be surprised.

This evening before going to bed, on her own without any prompting from Erin, she came into my office and said "thank you for bringing me a baby Chou Chou", and gave me a hug and a kiss. I'm so pleased that she recognized that something nice was done for her, and I'm more pleased that she had the presence of mind (even as a three year-old) to give thanks.

Recursion Alternative; or Non-Recursive Recursion

I learned a really neat trick today, (thanks again Karl) -- which I'll intentionally missname "non-recursive recursion".

I've used classic recursion (a funtion that calls itself until some condition is met) in the past to traverse up and down parent-child relationships. Recursion is especially nice when you don't know at the beginning how many decendants or progenators there will end up being at the end. The classic example is something like this: return all decendants of a given category where each category has x number of children (and x can be greater than or equal to zero).

I asked Karl about recursion in C# this morning, and he basically confirmed to me that it works the same way as I have been used to in ColdFusion, then with a smirk -- he offered an alternative. An alternative? There's an alternative to recursion? I was quite eager.

Here's how it works: a for loop is set up that loops over the contents of an ArrayList. Inside the loop you add to the ArrayList the child elements of the parent in the current iteration of the loop. If a child is found (and subsequently added to the ArrayList), then the ArrayList grows by x number of children elements. Now here's the rub:

The exit test on the for loop is always testing to see if the index is less than the count of the ArrayList.

As long as at least one child is found, the index will never be as great as the count of the ArrayList, and the loop continues. Beautifull!

In other words... if a child is found, this of course means the for loop will execute at least one more time, which itself returns the immediate children of the new parent (the current itteration of the loop)... et cetera, et cetera, until there are no children and the index of the for loop finally catches up with the count of the ArrayList, and the for loop exit condition is met.

So simple. So elegant. So.. je ne sais quoi!

Sunday, October 03, 2004

How to use the singleton design pattern..

Since my ColdFusion days, I've had a interest in software design patterns (I admit that my understanding of design patterns is really at the conceptual, not practical level -- that's changing though...).

I used my first pratical application of a bona-fide software design pattern today however: The Singleton. From what I gather, it's likely to simplest to understand and implement -- so... uh, it's nothing fancy.

The Singleton design pattern is used to ensure that only one instance, a "single instance" is ever instantiated during the life of an application. It can (and from what I understand, should) be used in place of a class composed entirely of static methods. The Singleton ensures that a single instance of the class is instantiated the first time a method in that class is requested, and then the same instance is accessed many times during the life of the application.

Implementaion of the Singleton requires applying three basic concepts:
  1. a protected constructor;
  2. a private static variable of the class type;
  3. and a public static method (typically named "instance") that controls the instantiation of new classes

Here's how it works:

  1. To instantiate a new class, the application calls the instance method rather than the typical "new class()" syntax.
  2. The intance method checks the private variable for null (meaning the class hasn't already been instantiated).
  3. If the protected variable is null, then the intance method calls the protected constructor which instatiates the class and returns the instance;
  4. if the protected variable is not null (ie: an instance already exists), then the instance method simply returns the already instantiated class.

Voila! Only one instance of a Singleton class can ever exists. It's really quite simple and elegant -- which I guess is what makes it really cool.


Saturday, October 02, 2004

Welcome J.D. to the World of Blogging

I'm here at J.D. Taylor's house, eating a Wendy's taco salad, and fixing his WAP. I'm posting this mostly just to show J.D. how cool blogging is.

Friday, October 01, 2004

A Night Out

Had a crumby day at work today, and I really didn't want to go out, but Sean was celebrating his birthday at Joey Tomatoe's, and we had committed to go see 'Hero' with Larry and Liana Kearl, so I went along.

Both the dinner and movie turned out to be good -- I sat beside Kelly McTighe at dinner (he's quite a nice guy -- kept me laughing througout dinner). We had fun going out with Larry and Liana, we've really missed being thier next-door-neighbours.

Reporting Services Symetric Key Error

I had a problem with SQL Reporting Services today, and came across the following post on SQL Junkies that resolved it.

The error was: "The report server cannot decrypt the symmetric key used to access sensitive or encrypted data in a report server database. You must either restore a backup key or delete all encrypted content and then restart the service. "

As it turned out, my user ID had changed, and I no longer had permission to run the report. The text of the SQLJunkies is as follows:

Did you change the account that the reporting services windows service runsunder? Or did that accounts password get reset?If you changed the account, you can fix this problem by:

  1. Change the account back to the original
  2. Run rskeymgmt -e to save the encryption key
  3. Change the account to the new one
  4. Run rskeymgmt -a to resave the key for the new user.

If the password was reset and you have not previously made a backup of the encryption key, there is no way to recover the data. You will need to runrskeymgmt -d to delete the encrypted content. Besure to restart IIS afterdoing that.