Devlico.Us
CodeBetter.Com
RSS 2.0 via Feedburner
           Do you Twitter? Follow us @devlicious

Derik Whittaker

Thoughts on Software Development, .Net, OOP, Design Patterns and all things cool

February 2008 - Posts

  • Nasty MSBuild Error - MSB4126 "Debug|HPD" issue

    Today I was trying to put together a simple NAnt build script for a 'play' project of mine.  This build script is real simple, it only calls MSBuild right now.  However, when I was running the script I kept getting the message 'error MSB4126: The specified solution configuration "Debug|HPD" is invalid.'

    For the life of me I could not figure out what this was.  I spent time on Google, and could not find anything useful.  What made this more strange was that I could compile via the solution file.

    Finally it dawned on me to check my Environmentimage Variables on my  machine.  About half way down was a variable 'Platform' with a value of 'HPD'.  I removed that variable, and rebooted, now all is right with the world again (ok, all is right with the build).

    Hope this helps someone else out, cause I know it was pissing me of.

    Till next time,

  • Simple Linq to Object example with Casting

    This is my first go at playing with Linq.  So far it is pretty cool, but I wanted to share something because I found it painful. 

    I wanted query a list and then cast a anonymous type to a static type.  I was not able to find anything on the net to help me with this (could be i just did not look in the right places) so i thought i would share my findings. 

    Below is the definition of the 'Sport' object

    [Serializable]
    public class Sport
    {
    
            public virtual Int32 SportID { get; set; }
            public virtual string Name { get; set; }
            public virtual string Description { get; set; }
    
    }
    

    Here is the code to query some data out of a list of sports List<Sport>

    List sports = new List();
    sports.Add(new Sport { SportID = 1, Name = "Sport 1", Description = "Sport Desc 1" });
    sports.Add(new Sport { SportID = 2, Name = "Sport 2", Description = "Sport Desc 2" });
    sports.Add(new Sport { SportID = 3, Name = "Sport 3", Description = "Sport Desc 3" });
    sports.Add(new Sport { SportID = 4, Name = "Sport 4", Description = "Sport Desc 4" });
    sports.Add(new Sport { SportID = 5, Name = "Sport 5", Description = "Sport Desc 5" });
                
    var query = from s in sports
    	where s.Name == "Sport 2"
            select s;
    

    The code below will show how to cast/convert from anonymous type to static type.

    Sport sport = (Sport) query.First();
    

    The code below will show how to cast back to a List<Sport>

    List newSports = query.ToList();
    

    Hope this helps someone else.

    Till next time,

  • Being OCD and Merging don't mix

    Let me start of by publicly admitting this, I am have OCD (Obsessive-compulsive disorder) when it comes to code.  My code must be clean and it must be uniform.  And because I am a ReSharper lover my disorder is even more drawn out.

    Over the past month or so while I have been fixing bugs in our application I have been making 'harmless' changes to the various class files that I have been editing.  These changes involve removing dead using blocks, removing dead code, removing unneeded 'this' usages, making various improvements to the code, so on and so forth.  None of these were major and none should (wish we had tests to prove this) affect the quality of the application.  But since ReSharper has highlighted these various issues I thought I would change them.

    Boy was that a bad idea.  Last week the team I am on had a directive to merge 3 different branches into our trunk and this needed to happen ASAP.  What I found out real early in our merge was we had TONS of conflicts or merge warnings because of all my 'changes' (VS Team's merge tool is not the best).  Almost all of issues were easy to merge, but the fact that we had to spend a ton of extra time on them was waste (should read these [book 1, book 2] for more information on removing waste).  We were able to get through the merge just fine, but it took longer then anticipated.

    The moral of the post is this.  If you have OCD in respect to code and you are going to be doing merges, try to control your OCD.  If not your merges are going to be much more painful and take much longer then needed.

    Till next time,

  • Rockford .Net group follow up

    Last night I had the pleasure of making the trip out to the Rockford .Net users group and presenting on TDD/Unit testing.

    The group was great, they asked a ton of great questions ranging from  testing, to Mocking and finally about IoC/DI.  If fact there was actually so much dialog and conversation I had to cut the presentation a little short as we were running out of time.

    I even think I was able to convert some non-believers (for a lack of a better term) into giving testing a try.  If this is case, then my presentation was a great success.

    Towards the end of the night we even had a guest visitor, a little gray field mouse.  I guess he also wanted to learn about TDD and testing.  Actually, given the fact that it was about 10 degrees out, the mouse was pretty smart to find his way inside.  I hope he learned something :)

    Thanks again guys.  I would love to hear feedback from anyone that was there that night.  What were your thoughts.

    Till next time,

  • How to Login to SQL Management Studio if your default database has been deleted.

    Today I had a weird issue, I could not log into SQL Management studio because my default database had been deleted (it was no longer needed).  Every time I would try to log in, I would get the following dialog.

    image

    At first I was kind of stumped, I did not know what to do other then email the DBA to ask him to re-map my account to another database.  Then it hit me, there has to be a way to change databases.  Sure enough there was a way, but it did not work the first time I tried it.

    image

    When I tried to select a new database from the drop down I got the following error message.

    image

    Now I was stumped on what to do, then it dawned on me.  Simply type the name of the DB I wanted to connect to in the drop down, don't try to 'select' it.  That worked..... YEA

    Hopes this helps someone else in the future.

    Till next time,

  • I will be at the Rockford (IL) .Net Users Group Tonight

    As I posted a while back (here) I will be presenting TDD tonight at the Rockford .Net Users group.  This is a 150 level overview of TDD and will dive into Mocking, IoC/DI and CI towards the end.

    The meeting starts at 6pm and should be a good time.  Swing on by if you are in the area and say hey, or simply stop by to heckle me (always fun).

    See everyone tonight.

    Physicians Immediate Care building in Machesney Park
      11475 N. 2nd Street
      Machesney Park, IL 61115
      (815) 654-8000

    Till next time,

  • Sound of one man testing

    Recently I was chatting with a friend of mine and he asked if a single developer could be successful following TDD on a team that does not follow TDD.  My simple answer was YES, they can.  But there are a few things you must consider.....

    How can they make a difference
    I am a firm believer that someone practicing Agile/TDD  can make a profound difference on a non-agile/non-testing (traditional, if you will) project. 

    Following TDD is more about your mind set and attitude then it is about the process in my opinion.  Because you are following a practice that forces continuous feedback, you will actually help the team learn.  This drive for continuous feedback will be what drives new information, new knowledge to the team.

    Lastly, who cares if you are on an island?  You can still make a difference. 

    Does the project get the full benefits
    No, but what the project does gain is light years ahead of what it would have had other wise. 

    Benefits the project will gain

    • Better code coverage
      Even if you only can cover 5% of the code in your tests, that is 5% less code to worry about

    • Increased code quality
      Do I really need to explain this?

    • Increased code reliability
      Do I really need to explain this?

    • As foundation to grow on
      Because you have taking the initiate to create the test plumbing (i.e. configuration, db setup, logging setup, etc) you have reduced the barrier of entry for other developers.  I have found that this barrier of entry is a common reason people don't want to start testing.  I know it is lame, but I have heard it.

    Will the team ever convert
    This would be nice, but don't expect it.  However, there are a few things you can do to increase your odds.

    • Prove your code is more reliably/stable due to your tests
      This is what you tests will do.

    • Show them how easy it is
      You will be able to show then that writing tests is not hard, that it does not double the length of time to develop the new feature.  You also be able to show them how you are able to flush out uncovered bugs very early in the process, thus saving everyone time and money.

    • Show them how clean your design is
      Because your code will DO ONLY what is required, they will be impressed by how clean your code is.

    • If all that does not work, beat them over the head with a Agile/TDD book till they cave. :)

    Issues to watch out for
    Because you are the only one creating tests, there are things you must be willing to accept.

    • Broken Tests - Non Compiling
      Don't expect the rest of the team to include your test projects in their solution.  In the past I have received massive push back because they don't want to waste the time allowing the extra projects to build.  Because they are not building your tests, be ready to fix various compile issues from time to time.

    • Failing Tests - Compiles, but does not pass
      Because your tests are not being run on any regular basis by the other team members, just assume you are going to spend a percentage of your day fixing broken tests.

    Till next time,

     

    Updated some grammar mistakes, thanks Andrew :) 

  • Hey JetBrains share the love with Devlicio.us too!

    Hey, JetBrains all of us over at Devlicio.us LOVE ReSharper just as much as the guysa at  CodeBetter.  Share the love.  Join our 'Friends List', I mean we are the 'spin-off' site of CodeBetter, we are kinda like distant cousins.

    Please be my friend, please.

    Till Next time,

    Ok, this is a obvious attempt to score some free goodies I know.  But a developer has to do what a developer has to do.

  • ReSharper 4 EAP is out

    All, you can grab this from here.

    You can get the release notes here.
     

    Till Next time,

  • The VS Team Branch Merge Dance Explained

    Just wanted to dump a quick how-to on doing branch to trunk merges in VS Team.  It is pretty simple really, only a few steps.

    1. Pull the latest of the branch to your local disk
    2. Pull the latest of the trunk to your local disk
    3. Merge and Pray (more on this at a later date)

    Yea sounds pretty easy right.... WRONG.  Tonight we spent 5 hours doing a very long, very painful, very tiring merge.  Only to finally realize that the person doing the merge (we were doing a group merge via desktop sharing because of what had changed) had not gotten latest of the trunk. 

    We all just assumed that it would merge with the latest in the trunk and not look at your local disk.  Boy were we wrong. 

    The entire time we were doing the merge, something did not feel right.  Well, that damn gut feeling was right again.  Oh well, we will try it again, this time with the LATEST.

    So, just remember, GET LATEST FIRST.

    Till next time,

    Derik the merge exhausted (sorry Kyle, had still your signoff this time) :)

  • Wisconsin .Net Users group follow up.

    On Tuesday I presented Mocking at the WI .Net Users group in Milwaukee and I wanted to thank Scott and the group for allowing me the time to come in and present Mocking.

    I thought we had a great turn out considering the weather, we got 3-5 inches of snow that day.  We have somewhere around 40 to show up, which was great.

    Giving this was my first time presenting I think it went pretty well.  I defiantly learned a thing or two about the process and what to expect.  Hopefully I will learn from this experience and make adjustments going forward.

    Thanks again guys.  I would love to hear feedback from anyone that was there that night.  What were your thoughts.

    Till next time,

  • Dead Code: Code Smell #1

    In my humble opinion the worst code smell you can have is Dead Code.  I know that other smells such as large methods, large classes, overly complex logic, interwoven dependencies, etc are all smells, but nothing, I MEAN NOTHING smells worse than dead code.  Let me explain.

    **** BTW, I am not talking about commented out code (which is another smell), I am talking about code that is actually executed, but not used *****

    In most systems today (even the good ones) code is not accurately commented or documented, if it is commented or documented at all.  As you are looking though code and you run across logic that 'looks needed' but is not being used, what do you do.  I assume you have to stop and ask yourself 'Should this be used'?

    Here is a classic example of why dead code smells.
    Lets say you are on the hunt for a pesky bug and you stumble into a method that you think is the cause.  As you are stepping though and reading the code you notice some dead code.  At first you pass it by thinking it is not needed, then you stop and take a double take.  At this point you realize that code may be useful, but since it is not being used, you have to start making assumptions.  Is the dead code an accident?  Was it done with intent? 

    Now what do you do?

    We all know that when you start making assumptions you are destined for trouble.  A good developer has to think that the previous author had good intent when they made their code changes, but since the code is left over, you are not sure what to do.  Because the dead code is left over you are at a cross roads, should I delete it, or should I try to determine how it was meant to be used.  It is here you get into trouble.  You are forced to try to put together the puzzle without enough information to make a educated guess.  If the original author would have just removed the dead code, the new author would be free to make his/her own decision on how to solve the problem at had.

    One other thing about dead code, it wastes cycle time.  You are slowing down your application by executing code that is not used.

    Moral of the story, if you are not using the code delete it.  Or, if you must, comment it out and tell WHY you are not using it so the next guy does not have to make assumptions.

    Till next time,

    ***** Note, if you are using Resharper, it will flag dead code for you.  This will make removing it much easier *****

  • That's right, I am Old School!

    Just to prove that some of us don't need new technology we had these shirts made up at work.

    IMG_1206 How needs all that new technology, give me VB6 or .Net 1.1 any day.

    WPF, WCF, WFF, .Net 3.5, Ruby, F#, Mocking, Testing it is all just a fad. 

     

     

    IMG_1207

    If you like the shirts, let me know, I can tell you where we had them made.

     

     

     

     

    BTW, these were made up as a joke at work based on a few conversations with a fellow developer :)

    Till next time,

  • I will be at the Wisconsin .Net Users Group Tonight

    As I posted a while back (here) I will presenting Mocking tonight at the Wi-Ineta group.  The meeting starts at 7 and should be a good time.

    Swing on by if you are in the area and say hey, or simply stop by to heckle me (always fun).

    See everyone tonight.

    Till next time,

  • Why I Love being a Software Developer

    This post is part 1 of a 2 part mini-series on why I both Love and Hate being a software developer.  This is mostly a semi-generic rant about my views on the software industry as a whole, and NOT about any one company that i have worked for.

    I have been a software developer for the past 8+ years, and every year I ask myself 'Why do I still do this?'.  The answer is pretty simple really.  I love it, it is the passion that drives me as a professional.

    Why I love being a developer:

    Because there is always something new/exciting to learn
    IT Rocks.  What other job can you learn something new EVERY day?  What other job can you find yourself wanting for more EVERY day.  Today more then before our industry is changing at the speed of light.  The sky is the limit right now on what we as a industry can do.  If this does not excite you, I am not sure what does.

    Also, you should NEVER become bored as a developer.  There is always something new to learn.  It could be a new language, a new tool, a new framework, a new design pattern or a new methodology.  The point is, you can code for 20+ years and never stop learning. 

    Soak it up, be the sponge.

    Because I have the opportunity to solve some fun and challenging problems
    Almost every day i have the opportunity to solve some crazy business problem. Sure some are better then others, and some are more fun then others, but it is still really cool.

    One of the most gratifying things for me is helping a business succeed.  It is really cool to see the fruits of your labor making a difference. 

    One of the really great things about solving problems is that there are so many possible ways to solve most problems.  You put 10 developers into a room and ask them to all solve the same problem, you will likely get 10 different answers.  This open and dynamic nature of our industry allows for crazy freedom and extremely rich rewards.


    The Great Communities
    The one thing i have come to appreciate over the past few years is the great communities that are out there.  Regardless if you are developing in .Net  Java, Rails, or what ever, there is a community out there.

    These great communities offer many things

    1. Friends
    2. Knowledge
    3. Jobs


    Because it is fun to be a 'Geek'

    Lets be honest.  Most people have no clue what it is we do on a daily basis.  Most of the time, the only people that have any clue what we do are our peers.  This is kinda cool.  I like the phrase 'I can do what you do, but you cannot do what I do'.  I know this does not apply to all professions, but most.  I truly believe that most developers can learn another profession and do it pretty well, but i doubt most others can learn to code and do it well.  (ok, i am on an ego trip in regards to developers)

    Even though we are 'geeky' we are also very well respected.  For proof of this just take a look at movies today.  How many movies have been released in the past 10 years where 'geeks' are made to look cool or even glorified.  If Hollywood gets it, it must be cool.

    Because the pay is great
    Ok, lets be honest, the pay rocks.  I know that I could not do anything else and make the same living.  Sorry, had to say this part.

    Stay tuned for why I Hate being a software developer.

    Till next time,

More Posts Next page »

Our Sponsors

Red-Gate!