hellswraith's profileCoding and BeerBlogLists Tools Help

Coding and Beer

They don't go together, but they should!
August 20

I am moving to WordPress

Although I first liked MSN Spaces, they are making things much slower.  So, I am moving to WordPress.  You can find my new blog at http://brianrussell.wordpress.com/ 
 
Hope to see you there, I hope to transfer the posts from this blog over.
 
Brian Russell
July 16

Team Work Learned By Video Games?

I was watching my daughter and her friend this morning play on the XBox, and realized I was watching them learn how to work as a team towards a common goal.  They were constantly communicating with each other telling the other person what they needed from them in order to do their part in the game.
 
I watched all the dynamics of team work at play.  They would get mad at each other when one strayed to do her own thing.  They would get mad at each other when one wouldn't communicate to the other what they were trying to do.  They learned what their partner needed from them in terms of communication, and started to provide it.  They shared joy when they solved a difficult problem, or when they finished a level.  The two person team had a leader, but the leader couldn't over step her natural authority because the other team mate wouldn't work with her if she was too bossy.
 
I was amazed that at age 9 the girls were able to quickly solve any teamwork issues and re-focus on their goal of progressing further in the game.  Maybe I read too much into things like this, but I really believe that what I witnessed today will provide my daughter and her friend with skills that will allow them to work with others throughout life.
 
Brian Russell
June 25

Guarding Clauses

I have been reading Jimmy Nilsson's latest book titled "Applying Domain-Driven Design and Patterns With Examples in C# and .NET".  In the refactoring section, he eluded to Guarding Clauses.  He put a name to something that I have been doing in my own development without knowing that others have talked about it as a good practice.
 
To be fair, he mentioned that it originated from Martin Fowler in his refactoring book.  Either way, it felt good to know that on my own I came up with something that others would consider best practice.
 
So, just what is a guarding clause?  Well, it is where you guard your code without mixing all the code up in if statements.  That is probably way overly simplistic, but below is a simple example to follow:
 
Here is a method before being refactored to use guarding clauses.  Notice that the two if statements have nothing to do with what the method is supposed to do, they are just there to ensure the variables are correct before executing the code that needs to run.  In affect, they are guarding the functionality in order for the code to run as expected.
public void DoSomething()
{
   if(_someVariable != null)
   {
      if(_someOtherVariable == "")
      {
          _someOtherVariable = _someVariable.ToString();
      }
   }
}
 
When you look at that code though, it just looks messy.  You could simplify it to this if you wanted to:
public void DoSomething()
{
   if(_someVariable != null && _someOtherVariable == "")
   {
      _someOtherVariable = _someVariable.ToString();
   }
}
 
Still, just doesn't seem right that the functionality of the method is in-cased in a if statement.  Using a guard clause, the method now looks like this:
public void DoSomething()
{
   if(_someVariable == null || _someOtherVariable != "")
      return;
 
   _someOtherVariable = _someVariable.ToString();
}
The benefit to doing it this way is really shown when the method has many more lines of code, but for the example I didn't want to confuse the concept with what the code does.  Further refactorings can make this code even clearer if you wanted to:
public void DoSomething()
{
   if(VariablesHaveNotBeenInitialized())
      return;
 
   _someOtherVariable = _someVariable.ToString();
}
We just extracted out the conditional logic to a new method to provide better readability to our code.
 
Our team has been using these concepts on our current projects with great success.  It is nice to glance at a method and realize that if conditions are not met, the code will not execute .  It is easier that trying to execute the code in memory to see what code will run and when.  Readability is key to this refactoring!
 
Brian Russell
 
 

TDD, BDD, and DDD oh my!

I haven't posted in a while, and thought I would catch everyone up with what I am doing.  I have been on a pretty deep exploration of Test Driven Development (TDD), Behavior Driven Development (BDD), and Domain-Driven Design (DDD).  That is a lot of 3 letter acronyms.

Why all of this at once you may ask?  Well, for me, I feel that a lot of this is all intertwined, and should be explored together.  TDD and BDD are so close that it is just your thought processes when you approach the testing that makes them different (from here on, I will just refer to both as TDD).  DDD goes hand in hand with testing.  Testing your domain model is important in order to effectively refactor when necessary.  Check out this video of Dave Astels giving a talk to Google employees about BDD.

It’s funny that it took me shifting away from everyday development in order to free my mind enough to look at the bigger picture of software development.  Sure, I could always handle any problem passed on to me because I felt comfortable with my technical skills to do so.  The problem was I never truly ‘designed’ my software well.  That was hard for me to admit for awhile, but I have since seen where I have been and where I want to go.  Most of this thought process came from the fact that I wasn’t ‘in the trenches’ everyday, doing the same thing over and over.

I got on this track of thinking by reading the writings of some very smart people on the subjects.  I found Jeremy Millers blog which totally enlightened me on TDD.  His blog is hosted on the CodeBetter.Com site which contains many other blogs that provide some great value as well.   Martin Fowler is another author whose work has been a great resource.  I can’t believe it took me so long to read Martin Fowlers work, but once I have, I can’t get enough.  Last up, I have been reading a book called “Applying Domain-Driven Design and Patterns With Examples in C# and .NET” written by Jimmy Nilsson.  I am not even half way through the book, but so far I really like it.

So, that is where I am at right now.  I am going to finish up the book, do a small project to solidify the concepts, and start integrating the knowledge learned into future projects.  I will post any worth while updates on my progress here as I go on.

 

Brian Russell

June 08

MSDN Wiki

This is pretty neat.  MSDN has a beta of their documentation with some added Wiki functionality.  What I think is neat is that if you are researching the help, and something isn’t helpful, you can add more information to it. Likewise, you can learn from others.  The documentation stays the same, but below it in the green area, you can add your own content.
 
Brian Russell
 
June 04

IPac - Fight for Individual Freedom

I was reading on Slashdot a article about how the DMCA has caused innovation of new devices to not occur because the law provides teeth for the Motion Picture and Recording industries to fight off devices they don't like, but benefit the consumers.  I have always been a bit upset about how big business gets to rule our country, and this is another problem that they have caused for the people.
 
So, I followed someones link in the comments of the post to the IPac site.  I am all for supporting a cause if possible, so here is a link to it if you are interested:
 
 
All political views are my own, and not necessarily the views of my employer.  This is a duh statement, but I wanted to make sure I at least say that when I am talking about politics.
 
Brian Russell
May 26

Stored Procedure Debate

I have found this ongoing debate about stored procedures interesting, so I thought I would post the links here so I can come back to them at a later time.
 
It all started with this funny post.  The last couple of sentences referred to stored procedures:
 
Next up came a general posting of why stored procedures are good:
 
Next, a response showing the other side of the argument:
 
And finally, a response to the response:
 
There will probably be some more, I will try to keep this updated.
 
Brian Russell
May 13

Motorcycle

I have been wanting a motorcycle ever since I sold my last one in 1998.  In the last few years, my dad and I have been talking about it more and more.  It looks like this is the year of the Motorcycle for our family.
 
It started when my brother expressed his interest in getting one.  The avalanche started and we have all decided on the bikes we want.  We are working with the dealership now to get the best deal (we are buying three at the same time after all).
 
Here is what I am looking at:
 

Blog From Word 2007

I have often wondered when it would be put into word, but blog posting is going to finally be integrated into Word 2007.  I am excited that they are going to support MSN Spaces since that is what I use, but they also support other blog engines.  They are allowing it to be extended, so if your engine isn't supported out of the box, someone will probably write support for it soon.
 
Now, if only OneNote had native blog support like this.  OneNote would be a great blog posting tool for me.
 
Brian Russell
May 12

ASP.NET 2.0 Membership and Roles

So I have been trying to come up to speed on the new ASP.NET 2.0 features.  I am just floored on how easy it has been to set up security on your websites with 2.0.  I have been reading a bunch of information online, but everything keeps coming back to this post by ASP.NET guru Scott Guthry
 
That might be the only ASP.NET 2.0 membership / role link you ever need since it spiders out to every other article needed.
 
Brian Russell