WinFX Feb CTP Installation Error

Posted by Jake Good
on Feb 28, 06

For those of you who are getting either one of the following errors:



During your Build Process of a WinFX Project:




Error 1 The "Microsoft.Build.Tasks.Windows.GetWinFXPath" task could not
be loaded from the assembly PresentationBuildTasks, Version=3.0.51116.0,
Culture=neutral, PublicKeyToken=31bf3856ad364e35. Could not load file or
assembly 'PresentationBuildTasks, Version=3.0.51116.0, Culture=neutral,
PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system
cannot find the file specified. Confirm that the declaration
is correct, and that the assembly and all its dependencies are available.


or



During creation of a new WinFX Project:




"Package Load Failure"
Package "PresentationDesignVisualStudio has failed to load properly (
GUID = {E582A8B-BCC4-4559-AD59-D62EB6D58A22} ). Please contact package
vendor for assistance. Application restart is recommended, due to
possible environment corruption. Would you like to disable loading this
package in the future? You may use 'devenv /resetskipppkgs' to
re-enable package loading.


Check out the following post to the newsgroups (I posted GooberDLX): post



The process seems to be simple to fix:




  1. Uninstall WinFX SDK.

  2. Move “C:Program FilesReference Assemblies” to a different folder (I renamed it to “_Reference Assemblies”).

  3. Repair WinFX RC Feb.



Try it out, let me know how it goes… I’m doing it currently and so far it’s working smoothly.



UPDATE



All I had to do was uninstall everything, delete the reference assemblies folder, and reinstall everything. Worked like a charm. In case you accidentally hit “Yes, I want to skip loading these packages” when you were recieving errors, just start Visual Studio 2005 from the command line with the /resetskippkgs parameter…

Freaking Sweeeeet

Posted by Jake Good
on Feb 28, 06

Check this stuff out: http://preview.local.live.com/



Think (Google Maps || Windows Live! Local || Mapquest) + Keyboard Driving



Do we even need to go out of the house anymore? Feels just like GTA, but at 2fps.

"A Christmas Story" - The Good Family Style

Posted by Jake Good
on Feb 27, 06

This is a complete repost from my old blog, but I re-read it and laughed uncontrollably… A short story that my younger brother, Tadd, wrote. This might fall under the “you had to be there” category…



Tadd Good



Professor Burm



English 101 10:45



01 September 2004



My Most Memorable Christmas



As I opened my eyes to look at the clock, I realized what day it was. This frigid winter morning was the just the beginning of a great Christmas. I peeped between the curtains near my bed and saw the beautiful, white, untouched snow that had fallen overnight. The windows had frosted over, making it difficult for the morning sun to pass through. Just like all kids my age, I had been waiting for this day all year long. Each year I promised to sleep in a little longer, but this year was no different. It was just after seven a.m. and I knew that both of my older siblings were still asleep. I just didn’t understand how they could sleep when there was so much to do. Determined to have all of my gifts unwrapped, opened, and ready for action within an hour, I began my awakening ritual. Making as much noise as possible, I violently stomped down the clunky steel ladder of the bunk bed that my older brother Jake and I shared. Each footstep caused a loud ring from the metal vibrating against the frame of the bed. Jake, being the lazy teenager he was, angrily squinted his eyes open and groaned in obvious disapproval. After seeing me on the ladder and remembering what day it was, he rolled over in submission, realizing there was no option but to wake up. Stretching and yawning, he threw me one last glare before we headed towards the living room.



We slowly made our way to the living room where the giant Christmas tree was waiting. Our parents were expecting our early arrival, and they were armed with tall mugs of coffee. Jake and I gazed in wonder at the array of colorful gifts that had been stacked under the glowing tree. As the youngest of three kids, it was known that I would receive more gifts than anyone else. This didn’t exactly make either my brother or sister very happy, and they let everyone know one way or another. I eagerly approached my parents, fearing for the worst.



“Mom, can I start opening mine yet?” I asked with a huge smile.



“Tadd, you know we can’t start without your sister here. Just let Jessica sleep a bit more.”



Jake knew very well that it wasn’t possible for him to fall back asleep, so he was determined to wake his younger sister up one way or another. Like usual, Jake was devising an evil plan in his head, a plan he knew he wouldn’t be executing. He knew that as long as he didn’t actually follow through with his plans, he was off the hook. That’s what little brothers were for. I would have done almost anything he told me to, and he used this to his advantage. While our parents shuffled into the kitchen for a refill of their highly caffeinated coffee, Jake challenged his plot to me.



“I dare you to just blast into Jessica’s room and jump on her bed. That should wake her right up!” he said with an evil grin.



Being the naïve youngster I was, I decided to take his idea and run with it. I was determined to wake my sister up, make my brother laugh, and to rip my presents open as soon as I possibly could.



I slowly crept to the coat closet to construct a suit that was both funny and scary. I thought back to the old black and white mystery movies and decided that every good disguise needed something covering the face. I slipped on my black cotton ski mask I had used to play in the snow earlier that week. Now I needed something to cover my body. My mom’s long, wool, dress coat looked like it was straight from a movie set. Pulling it over my scrawny shoulders, the bottom of the jacket touched the floor, covering my bare feet and Mighty Duck pajamas. Looking at myself in the mirror, I realized my outfit was a bit too scary. I decided to add a few accessories to tone down the mobster look of my attire. Sliding my mom’s oversized sunglasses from the interior pocket of her jacket, I knew they would go great with my ski mask. My outfit was almost complete. Grabbing the nearest object, my sister’s maroon umbrella, I headed down the dark hallway to my destination.



Tiptoeing through the hallway, I began to have second thoughts. I wasn’t sure if I was going to make her scared for her life or make her cry laughing. Either way, I knew I would get a reaction, so I decided to go for it. When I reached her bedroom door, I read the home made paper sign that read “do not enter.” Ignoring it, I inhaled deeply, unsure what would happen in the next few seconds.



I raised my arms above my head, ready to strike. With all of my force and strength, I slammed my fists into the door, sending it swinging into the wall. I entered the dark room screaming like a banshee. Swinging the open umbrella over my head, I yelled her name at the top of my lungs in the most terrifying voice any grade-school kid could attempt.



“Jessica, Jessica, wake up now!” I yelled.



As soon as Jessica caught her first glimpse of me, it was as if she had seen a ghost or Satan himself. Clutching her chest for air, she jumped back into the corner of her bed. Her eyes showed fear I had never witnessed before in my life. Her bed rattled against the walls as she slammed her back into the steel frame and shook in utter fear. She screamed for help in a scared, whimpering voice.



“Oh my god! Somebody help! Help!” she cried.



Tears began to stream down her cheeks as she thought her life was over. She clutched the bars of her bed, making her muscles stand out and her knuckles white. In a panic myself, I tried to calm her down as quickly as I could by ripping off my mask, revealing my face.



“Calm down! I’m sorry! It’s just me, Tadd!” I reassured her.



After gasping for air and finally catching her breath, she looked at me with fire in her eyes.



“I seriously hate you so much! What is your problem?” she asked as she wiped the tears from her face.



“Merry Christmas!” I said with a nervous smile on my face.



In the other room, I heard my brother rolling on the floor in a fit of laughter. This was a Christmas that nobody would forget.

where did the weekend go?

Posted by Jake Good
on Feb 27, 06

Don’t you love those weekends where from Friday immediately after work until Monday morning at work… all you did was either sleep or party?



:: yawn ::

4 things meme

Posted by Jake Good
on Feb 25, 06

I was tagged by Mike… so here it goes.



Four Jobs I’ve had…




  • Bus boy, cook, cashier at Scotty’s Restraunt and Dairy Bar

  • Peon at Shopko

  • Residential Assistant at UNI

  • President / VP / Treasurer / Secretary of my own company. (for 1 year, mwuahaha)



Four movies I can watch over and over…




  • Shakespeare’s Romeo + Juliet (1996)

  • Stewie Griffin : The Untold Story

  • The Goonies

  • The Never Ending Story



Four TV shows I love to watch…




  • Entourage / Rome / HBO Series in General

  • The Family Guy

  • That 70s Show

  • Saved by the Bell



Four places I’ve been on vacation…




  • Washington DC

  • Kiawah Island, SC

  • Las Vegas, NV

  • I don’t go on vacations much…



Four favorite dishes…




  • Chicken Lips and Baked Potato Soup

  • New York Strip with Loaded Baked Potato

  • Strawberry Short Cake

  • Breakfast scramble / mess



Four websites I visit daily… (I don’t visit any sites daily but these would be the most frequent):




  • www.bloglines.com

  • www.penny-arcade.com

  • www.thoughtstoblog.com/mint (my egotistical statistics package)

  • www.myspace.com (im a junkie)



Four places I’d rather be…




  • In a movie theater

  • In bed

  • On my bike

  • In a science lab, doing research



Four bloggers I’m tagging…



i gave in

Posted by Jake Good
on Feb 24, 06

I am one of the few geeks out there that doesn’t have some sort of external storage device (ie. thumb drive, flash hd, or external hd).



I finally caved. Why? Because of this freaking sweet USB thumb drive at ThinkGeek.



HAL 9000 USB Flash Drive


1gb of pure intelligently artifical goodness.

isn't she gorgeous?

Posted by Jake Good
on Feb 23, 06

yeah… I just wanted to post a pic that my best friend Jaclyn sent me.



best friend and her roomate

wow, mmm mmmm mmmmm



It’s her with her roomate. (Jackie is on the left) Love those eyes girls, keep it up… if you need help with all those men chasing you, you know who to call. I got your back.

WinFX February CTP

Posted by Jake Good
on Feb 22, 06

So I just got done chatting with Kevin Moore about XBAP applications and their advantages / disadvantages… hopefully I’ll throw together some neat little articles focused in around that. We’ll see.



Congratulations to the WinFX team on their latest CTP drop. Get the bits NOW!



I’m integrating Windows Presentation Foundation with one of my other projects (which has yet to be announced)… so I don’t have any material yet, but feel free to check out Mike’s site. I hear he has a few articles up.

Conversation with Scarface

Posted by Jake Good
on Feb 22, 06

Setting: Tony Montana is sitting behind his large desk, with a pile of coke. Jake is sitting in a relaxing leather chair, discussing business with the Cuban coke lord.



scarface


Tony - How chew doin meng? You got shit taken care of?



Jake - Yeah I’m doin’ alright Tony, how’s your sister doing?



(Jake winks)



Tony - What the fuck chew talkin’ ‘bout? Don’t fuck around with my sister okay… you got any idea who I am?



Jake - Yeah you’re Al Pacino… err Scarface… umm Tony Montana.



Tony - Jake… don’t you FUCK me with meng, I’m the last bad guy on the fuckin’ planet meng.



(Tony bends over, sticks his nose in the coke… snorts)



Jake - Are you ok? Are you sure you should be snorting coke?



Tony - It’s sugar… First you get the sugar, then you get the money… then you get the power, and THEN you get the wommmeeennnn…



(Tony winks, Jake laughs)



Tony - What chew say meng? What the FUCK did chew just say meng?



(Tony gets up, walks to the cabinet, slowly opens it)



Tony - Say ‘ello to ma lil’ frien’!



(Tony spins around and starts firing rounds at 15 rounds per second)



(Jake flies behind the desk, jukes, runs to the door)



Tony - Come here chew little bitch, see what happens when chew mess wit’ Tony Montana.



Jake - FUCK YOU MENG (in a slightly mocking tone)



(Tony continues to fire as Jake lands in the infamous “The World is Mine” fountain)



Narrowly escaping, Jake whipes the coke off of his sleeve and walks home… continually watching his back.

moving on up

Posted by Jake Good
on Feb 22, 06

So it’s official… I have been promoted :)



I’ve been going through the career development process for a few months now and it’s finally paid off!



My official title is now: Application Development Senior Consultant



I get new business cards!



w00t!

a new theme

Posted by Jake Good
on Feb 21, 06

I was browsing through the Typo Trac (here) … and noticed a new theme submission.



A few changes were in order:




  • Changed pink text to red.

  • Changed pre tags to grey on black instead of bright green on black.

  • Removed the About Me page element and kept my static sidebar. (Had to remove the Rico js line in the default.rhtml.



It rocks! Richard White has some skillz, you better believe it..

Guitar Hero = Freakin' Amazing Fun

Posted by Jake Good
on Feb 20, 06

Welcome to Thunderdome, bitches! HAHA. Anyway welcome to my first guest blogging experience. This is Tom Johnson, I will be your blogger for the evening. Tonight I would like to share with you my current videogame addiction called: Guitar Hero.



Notice here my friend Rod as he plays the guitar controller, notice the screen shows the notes you must play, brilliant!



Guitar Hero1


The game is for the rock star in all of us. It has everything from classic rock to modern punk and everything in between. Well worth 70 bucks and a crappy PS2. Buy a used one, haha.



Guitar Hero Jammin'

funny quote of teh day

Posted by Jake Good
on Feb 20, 06

"I'm pretty much a ride or die bitch..." - The Beckster

on turning 25

Posted by Jake Good
on Feb 20, 06

So over the weekend I turned 25. Yeah, for as much attention as I love, I don’t really like expressing the fact that it’s my birthday…



At any rate, my good friend Tara came up… and along with Greg, we hit up Uptown for dinner and drinks. It was a good time… met up with Vish and Ben, which it happened to be Ben’s wife’s birthday as well! Who knew? February the 18th is a popular birth day choice amongst women it would seem.



At any rate, I am now half way to 50… but you wouldn’t know it :)



birthday

turning 25 like nobody’s business.



Our “So Fly” group…



birthday

the group

Conversation with Arnold

Posted by Jake Good
on Feb 17, 06

Setting: an office break room, Jake is sitting at the table, enjoying a refreshing Sierra Mist…



(The brick wall gives way… bricks flying everywhere… through the cloud of dust, Schwartzenegger appears)



Arnold - GET TO THE CHOPPER!!!! GET TO THE CHOPPER NOW!!!!



Jake - Arnold Schwartzenegger? Is that really you?



Arnold - GET DOWN…



(Jake crouches)



Jake - What?



(Jake stands when nothing happens)



Arnold - GET DOWN AGAIN!!!!



Jake - Ok! Ok!



(Jake crouches)



Arnold - We must get out of here, they are trying to take… your torillas.



Jake - This is freaking awesome! What are we going to do next?



Arnold - I’m going to ask you a few questions… and I want them answered immediately.



(Arnold pauses for a breath)



Arnold - Who is your daddy and what does he do? Your clothes, give them to me… NOW!



(Jake removes his pants, hands them to Arnold)



Jake - Are you going to like… autograph my boxer briefs or what? I don’t have a sharpee.



(Arnold grabs Jake’s hand and starts to run)



Arnold- Come with me, if you want to live…



(They exit the break room).

Have a Mint (1.27)

Posted by Jake Good
on Feb 17, 06

So in the world of web hosting, one of the services that is constantly provided is statistics, logs, and packages that can help you analyze your traffic.



Enter in “Web 2.0”, the craptacular buzzword that is catching everyone’s eye… and creating havok with a dot-bomb essence.



Most of the packages out there are kind of boring, look dull, or are just plain… why not having something that performs well, looks good, and gives you just the right amount of information.



A perfect example: Mint



A live demo: http://www.designologue.com/mint/



It’s pretty gnarly, has an interesting plugin system called Pepper, and is pretty extensible. Hell, even topfunky created a ActiveRecord model for Mint. I suggested placing a simple finder in there so that your Typo resource can call Mint to gain any statistics it can. Example: “Roughly 5 people have viewed this article in the last two weeks.”



Pretty sweet stuff, for $30 it’s a steal…

Conversations with < insert name here >

Posted by Jake Good
on Feb 16, 06

It’s Thursday, I’m out at a client site… and I’m being distracted by a new idea.



Here’s the skinny:



Once or twice a week, I’ll select an individual, whether he/she’s famous or made up is entirely up to me and the readers, and we’ll have a made up, humorous conversation with that individual. It’s pretty simple, but mixed with some sarcasm and wit… it could turn out to be quite the interesting read.



I ran this idea by a few people and they all seemed to like it. We’ll see how it goes.



I know I always ask you guys for feedback… but I’d like to know who you would want me to have conversations with. A few suggestions already: God, Obi Wan Kenobi, Bill Gates, and Neil Patrick Harris.

Moving Images in February

Posted by Jake Good
on Feb 14, 06

With Valentines day nearly over… I had to go out to find that perfect date movie. One with a good love story, beautiful people, a tear jerker scene, 10 Oscar nominations, and Jude Law.



It just so happens that I found something that only fits one of the traits… with the inclusion of the hot “Lucy” actress from 7th Heaven, Beverly Mitchell, the goal of finding something with beautiful people in it was easy.



"wow"



I digress. So back to finding the right movie… ahh yes, Saw II was something that I wanted to see in the theater, but with my busy lifestyle, I was forced to wait till today when it came out on widescreen DVD format.



If you saw Saw (mwuahaha) then you might have a clue as what to expect… but you’re wrong. I can’t explain much of the plot as it would give away the movie. Essentially it’s a psychotic thriller / borderline slasher that bends the mind and twists the plot. Great for the people who watch a movie and think they know what will happen… and then the “oh sh*t” comes out.



Comparing this movie to the first, I would have to say that it broke the inevitable “sequel fate” and actually outdid the original. The bad acting was still present but not as noticable. The killer and methods were outstanding as always… for the sick and twisted, almost an “Ohh Wow, that’s clever” kind of reaction.



All in all I say it’s a great movie pickup, even if you do watch it with your loved one(s) on Valentine’s Day.

a problem with your brrreeeport

Posted by Jake Good
on Feb 14, 06

seems as though there is a problem with your brrreeeport

tonight's plan

Posted by Jake Good
on Feb 14, 06

Jake’s Valentines Day plan:




  1. Drive home. Yuck

  2. Lose 3 lbs. of curls off the top of my head.

  3. Swing by Target and pick up Saw II on DVD.

  4. Hit up Leeann Chin’s for some dinner.

  5. Watch some bloody, clever killing.



It would be much nicer with company… we’ll see what happens.

book ideas

Posted by Jake Good
on Feb 13, 06

I have been tossing around the idea for the last few years to write a book. Everytime it comes to mind I always spend most of the thought process trying to figure out what type of book and what subject to write on.



I’ve contemplated writing a technical book. The vast range of technologies and topics would easily allow me to focus in on one idea/concept. I could do anything from Ruby on Rails, .Net Development, Genetic Algorithms, SCM, Agile Development… the list goes on and on.



I’ve also tossed around the idea of writing a mockery of a “Self Help” book with John. Maybe even a novel.



The bottom line is: I have a goal to publish one book within 5 years of graduating college. This will be my 4th year out…



What do you guys think I should write about? Any ideas?

Topological Sort v1.0.0.0

Posted by Jake Good
on Feb 12, 06

So a week or so ago I introduced topological sorting to the .Net world… but I didn’t give you the entire source to the solution, just a quick snippet.



Enter in subversion. If you know how to use svn, go ahead and peep the source:



This software is distributed under the MIT License (included in the code).



latest:




svn co http://developstuff.googlecode.com/svn/topologicalsort C:DevelopStuff.Examples.TopologicalSort


So far, I haven’t asked anyone to contribute to the project… as it’s merely an example, but now that I have my svn repository up, you’ll see source for my other side projects.



I would also like to state that if you haven’t read this book, you should go read it: Pragmatic Version Control using Subversion by the Pragmatic Programmers. An excellent read for anyone who wants an easy way to do SCM.



Resource: Using Subversion on Windows

Daniel Tosh - true stories i made up

Posted by Jake Good
on Feb 09, 06

I have to say, I’m a huge fan of stand up comedy… I’ve posted about it before on whoisjake.com/blog.



Recently I saw Comedy Central Presents with Daniel Tosh and HAD to purchase his new cd.



"Daniel Tosh"



Absolutely hilarious. People know me for some of the bullshit stories that I make up but this guy definitely takes the cake. His jokes are out of control hilarious. He’s quite edgey with his comedy which is great.



go buy it



here’s a teaser line:




"I love the internet...
because now we have rappers who used to be gangsters
and thugs telling us not to download their music,
because it's *stealing*...
:: choke :: Ohh I'm sorry, I'm choking on irony."

last night's date

Posted by Jake Good
on Feb 09, 06

So as some of you may have heard, Anna and I had our first date last night! =)



She escorted me to Bonfire on Grand Ave. It was a nice little joint. Quiet. There was even a candle on the table. Everyone together now: awwwww. I tasted the “Lake and Land” plate while she got a huge steaming pile of vegetables for her fajitas (spoken like Peter Griffin). After that we chilled on her couch watching the Grammy’s.



It’s great being in this discovery phase of a relationship, it’s been far too long since I’ve actually done the whole “dating” thing since I’ve been up here. Often enough, I’ll meet someone and it won’t take off anywhere. It’s a nice change.



How crazy is this? We were both in the backup band for our highschool showchoirs AND we both played the saxomaphone. How f’n weird is that?



It was too bad that I had the sniffles… otherwise I would have gotten a good night kiss. ;)



(p.s. yeah i know i’m being all giddy and shit, i can’t help it…)

svn access

Posted by Jake Good
on Feb 08, 06

So it looks like my host Dreamhost started experimenting with svn over HTTP.



Sweet…



What does that mean for you? More code being released by me at http://source.developstuff.com



soon enough

thank YOU chuck norris

Posted by Jake Good
on Feb 07, 06

with all of this stuff going around about Chuck Norris, I think that this takes the cake.



Who is the Master Chief?



"Chuck Norris"



FUCKIN’ CHUCK NORRIS IS!

the weekend

Posted by Jake Good
on Feb 06, 06

I’m not going to ramble much about the weekend, because if you know me personally and actually cared about how things went… you probably already know from my ramblings…



But I will say that the weekend was awesome. Friday went VERY well as did Saturday night.



I just hope that I can have more weekends like that and that I didn’t play all my cards in the last few nights…

i got called out

Posted by Jake Good
on Feb 02, 06

Looks like Mr. Rory “I’m So Cool, Funny, and “micro”Soft.” Blyth has called me out.



“I’d make you one of my posse, but you’re not sinister enough.”



I see how it is… Somehow eating food stacked with preservatives and penis shrinking dyes somehow makes you more sinister than packing heat, Nintendo HEAT (original SILVER model).



It’s ok, I understand where this is going Rory… you try to make peace with me, offering me a chance to “make the night sky shed tears”, enticing me with “let’s make my phone do cool things other than make phone calls, like surf the web with some lame ass browser”… yet all along you want someone to make you a “Rory Blyth Has a Posse” teeshirt.



You aren’t getting one… it’s not going to be the stars in the night sky that are shedding tears tonight in their bed, cuddled up against their little stuffed mircobes, watching The Notebook, crying as Allie’s cruel mother bashes Ryan because he only makes $0.35 a day at the mill…. now there’s your villain.



What you do to Ewok’s comes right back at you two fold. I’m not going to be suprised when you wake up one morning… tracks of those crazy MVPs across your “stylish” flat in Seattle… with Bantha fodder smeared all over your cheesy-poof covered ass, wrapped in opaque green saran wrap and the Ewok being rescued.



If anyone is thinking of taking his side… just be careful, I think he has the limited edition Herpes microbe.

Topological Sorting

Posted by Jake Good
on Feb 02, 06

When it comes to implementing algorithms, it’s always useful to write it out in psuedo code or at least obtain the algorithm in some form to work with.



At work, we typically use a form of data mapping layer that relies on Martin Fowler’s documented Unit of Work pattern. A problem that arises while using this pattern is dependency ordering for when you commit a unit of work.



Imagine if you will, you have a Parent object and a Child object that has a reference. In order for it to save to certain data store scenarios, you have to commit the Parent before the Child. Think “foreign key relationship” for common databases. The Unit of Work has to rearrange it’s elements internally so that when it goes to commit an object, it’s predecessors and dependency needs are taken into account.



This is where Topological Sort comes in. It essentially takes a graph with edges and outputs the nodes in such a away that all of the preceding nodes get spit out before their dependant nodes. This solves our Unit of Work problem by ensuring that the Parent objects will be committed before their respective Child objects. The only problem it introduces is that it fails when there is a circular reference, but with most data stores, you aren’t allowed or shouldn’t be allowed to have circular references that depend on each other.



The algorithm itself is pretty simple:




while graph is nonempty do
if Q is empty then
you have a cicular reference.
remove a node n from Q
output n
for each node m with an edge e from n to m do
remove edge e from the graph
if m has no other incoming edges then
insert m into Q


If you’re interested, the Big-O of this aglorithm is O(|V|+|E|) where V is the number of nodes and E is the number of edges. Not bad, could be better… could be worse.



The difficulty in this algorithm, applying it to our problem is that it requires a lot of meta data about the “nodes” of the graph. In our case, we need to know that an object is indeed, a real predecessor to another object.



Instead of quickly trying to fit it into our existing solutions, I took a baby step and began with a simple graph implementation.



We have some nodes:




Node nodeOne = new Node();


The each contain a collection of incoming edges (Parents) and outgoing edges (Children).



The C# (.Net 2.0) implementation of the actual sort is pretty straight forward. What you don’t see below is the method GetRootNodes(List<Node> nodes). All this method does is find the nodes that don’t have incoming edges (Parents).




public List Sort(List nodes)
{
List sorted = new List();

// Queue up the nodes that don't have any incoming edges.
Queue rootNodes = this.GetRootNodes(nodes);

while (nodes.Count > 0)
{
// if you have nodes, but no nodes
// that don't have incoming edges,
// then you've got a circular reference.
if (rootNodes.Count == 0)
{
throw new ApplicationException("The graph contains a circular reference.");
}

// grab the first start node.
Node n = rootNodes.Dequeue();

// add it your output.
sorted.Add(n);

// for each of it's dependancies,
// remove the incoming edge,
// queue the node,
// then remove the original node from the graph.
for (int i = (n.Children.Count - 1); i >= 0; i--)
{
Node childNode = n.Children[i];
n.RemoveChildNode(childNode);
if (childNode.Parents.Count == 0)
{
rootNodes.Enqueue(childNode);
}
}

nodes.Remove(n);
}

return sorted;
}


There you have it, plain and simple. I wrote some tests that verify the sort but the interesting thing is… the sort can theoretically produce multiple valid outputs. Luckily my test doesn’t check the actual order, but merely that the ones that need to appear first always appear first; by checking indexes of nodes.



The caveat to this is the meta data that is available. Each child node knows about it’s parent node. The difficulty in applying this method to a Unit of Work is that the relationship data might not be available or you might have to poll for more meta-data to make the decisions about edges. This specific implementation is also dangerous as it is destructive to the objects that come in, the line : n.RemoveChildNode(childNode); . Though this can easily be avoided by creating collections of meta data, rather than manipulating the actual collections of edges, I decided to be destructive for the sake of sharing an example and letting you figure things out for yourself.



Another trick you can pull is change the Queue to be a Stack. The nature of the outputted nodes is affected. Using a queue, it does a breadth-first search through the node trees, going the breadth across the outgoing edges (Children). If you change it to a stack, it does a pure depth-first search through the outgoing edges (Children). How does this affect the Unit of Work? Essentially all of the related objects will be inserted in more tight-knit groups, rather than just after the fact.



In conclusion, this kind of knowledge can be applied to numerous different areas of software development. It just so happens that it solves a lot of our problems in our frameworks we use everyday. It’s two fold. One on end, it shows us the value of using psuedo-code to express our ideas and on the other end, it shows us the importance of a well thought out and tested solution that might not have been thought of. I bet you don’t think about graph theory everyday while you’re writing code…



The code listed above does not intend to be perfect, production level code. Use it at your own risk. It is meant to be an example and should be treated as such.



References:



Wikipedia : List of Algorithms



NIST Dictionary of Algorithms

my thoughts exactly

Posted by Jake Good
on Feb 01, 06

today’s Dilbert was quite hilarious…



"Dilbert"