Public musings, often on software development RSS 2.0
# Wednesday, November 16, 2005

So one of the new features I've found with Static Code Analysis in Visual Studio 2005 is that it allows you to suppress messages.  As I blogged earlier, the typical behavior is for the tool to add a line to your source file to suppress a warning that you find to be unnecessary.  So I was playing with the Namespace related rules which allow you to try and keep variables named appropriately and it flagged the namespace name I used.  I have an acronym as my Namespace and that meant it’s all capitals which of course the rule didn’t like.  So I decided to ignore the warning, only this time since the warning occurs across several files instead of adding a line to each file which referenced the namespace the Static Analysis tool created a new source file called GlobalSuppressions.cs and added the suppression line to that file.  Here are the contents of this new source file in my project:

[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1705:LongAcronymsShouldBePascalCased", Scope = "namespace", Target = "IKRulz")]

 

As you can see the only thing in the file is the declaration to create an exception for that rule, but in theory I could add other rules to this file if I found the same message in several locations in my code allowing me to limit the number of times I needed to exclude a particular message.  Of course I could also just avoid running certain rules, but that’s a different discussion.

Wednesday, November 16, 2005 9:34:24 AM (Pacific Standard Time, UTC-08:00)  #    Comments [0] -
.NET | Team System | Technology

With the loss of easy access to Flight Line we've resorted to our older route through Calavera.  So this morning at 6:30 we did about an hour on the basic loop through the trails of Calavera.  Eventually we'll look at tracking a time, but the thing with our Calavera route is that we tend to stop at the route's high point.  The view is spectacular, the picture below doesn't nearly do it justice... to put it in perspective about 10 degrees to the right of the power plant was a large white container ship that was visible from the point we call the office - but which just can't be seen in the low quality camera phone picture.... 

Wednesday, November 16, 2005 9:20:47 AM (Pacific Standard Time, UTC-08:00)  #    Comments [0] -
Cycling
# Tuesday, November 15, 2005

One of those things which you need to do every so often and it takes longer then it should to remember how... and even Google does a poor job on a quick search of returning the simple step you need.

After you type in the FTP://site/dir to your browser (and probably gotten a credentials required message) you need to go to the file menu.  On the File menu select "Login As..." and then enter the credentials for the FTP site you are trying to access.  It's simple just not something most of us need more then about once or twice a year.

Tuesday, November 15, 2005 3:04:50 PM (Pacific Standard Time, UTC-08:00)  #    Comments [0] -
Technology

I've been remiss on my bike updates and wanted to get a quick one in for a few pending items:

First off I'm proud that I managed to meet my mileage goal for the year.  The odometer on my bike turned past 5850 this morning meaning I have my 2000 miles for this year.  So my new goal between now and year end is to get past 6,000 miles so I can say that I've averaged 2000 miles a year since getting my road bike.


Secondly I wanted to record for posterity (my benefit) my times to work in the morning so I can have a long term record and appropriate expectations.  Riding down the coast my goal on reaching the office is to have an average speed of 17.5 mph.  My last 4 rides were:

  • 17.6 mph for a riding time of 28 minutes 20 seconds
  • 17.8 mph for a riding time of 28 minutes 12 seconds
  • 18.2 mph for a riding time of 27 minutes 22 seconds
  • 17.6 mph for a riding time of 28 minutes 22 seconds 

Note I've been measuring speed to the start of the office lot and then I don't pick up the time until after I park my bike so there is a little slop on the time side.


Next up I wanted to mention the loss of our typical entrance to the flightline area.  We've seen the construction crew dig like a 30 foot hole on our old path.  Fortunately the anonymous trail guy has been at work.  There is a new entrance that allows access to the trails we've been riding.  It's back by the skate park and is too steep to ride up and to be honest I'll be concerned about riding down it.... but it is there.

Anonymous trail guy has also put in a bridge for the crossing from Calavera to Flightline so transistioning between the two areas is much easier.  Anonymous trail guy does some amazing work if you ever get a chance to see that bridge on this crossing (or if I manage to remember to post a picture).

Tuesday, November 15, 2005 10:30:11 AM (Pacific Standard Time, UTC-08:00)  #    Comments [0] -
Cycling
# Sunday, November 13, 2005
Time to show I do sometimes surf and that I don't only think about biking and software. One of those 'quizes' which matches your personality to some category. This one was based on Tolkien's Middle Earth. I had one question on which I was undecided... it apparently makes a difference in my result on the one answer I get:
Hobbit
but if I go with my other option (both were pretty much equal in my mind - should great deeds be remembered in tale or by renaming a street or town were my two equal choices.
Dwarvish
To which race of Middle Earth do you belong?
Fact is the second of these is probably more me today just as Merry and Pippen would not have been as true to the typical Hobbit nature and a bit more Dwarven after their adventures.
Sunday, November 13, 2005 9:42:39 PM (Pacific Standard Time, UTC-08:00)  #    Comments [0] -
Musings
# Friday, November 11, 2005

When working with the Team System Static Code Analyzer there are times when the tool will throw out an issue that isn’t something you are going to resolve.  Of course when you first run the code analyzer it’s not uncommon to have a list of literally hundreds of potential issues.  As I’ve discussed in the past, the best solution when this list is long is to use the configuration settings to limit the areas of focus to things like performance and security and then move on to other areas.

 

However, as you are processing your potential issues, the fact is that some of those items won’t be issues.  It’s very possible that the tool might warn about code which in fact in the limited context where it is used is implemented correctly.  As such it’s important to be able to make those issues disappear from the overall list.  In fact let me provide some sample code:

 

    private void stackButton_Click(object sender, System.EventArgs e)

    {

      foreach (ToolStripItem item in this.stackStrip.Items)

      {

        if (item != sender && item is ToolStripButton)

        {

          ((ToolStripButton)item).Checked = false;

        }

      }

    }

 

So if you take the method above you’ll see that it is referencing an untyped collection of items, and by reviewing the ‘if’ statement we can tell that it is looking for one of multiple possible types in that collection and then casting and using objects of that type.  Pretty straightforward and in the context of what it does I don’t see a better way of handling what it’s doing (you are welcome to educate me in the comments section…)

 

When I run this code through static analysis what I get is the following performance related warning:

 

CA1800 : Microsoft.Performance : 'item', a local, is cast to type 'System.Windows.Forms.ToolStripButton' multiple times in method StackView.stackButton_Click(Object, EventArgs):Void. Cache the result of the 'as' operator or direct cast in order to eliminate the redundant castclass instruction.

 

However if you look at the code the fact the casting from a functional standpoint is done only one.  There’s no real redundancy of the casting instructions and no reason to cache the results.  So what should we do, well we should indicate in the code that this condition has been reviewed and isn’t something we want to be warned about.  Right clicking the error in the error list I select the “Suppress Message(s)” option from the context menu and the current warning is shown with a strike-through font.  On subsequent builds/checks the error is not displayed.

 

Which begs the question of how does Team System implement this rule exception?  The answer is that it adds an attribute to my source code.  This attribute is actually a method call which tells the code analysis engine to ignore one or more rules in the scope of the current method call.  Below is the instance of the SuppressMessage call attribute for this example message.

      [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1800:DoNotCastUnnecessarily")]

 

This call allows the code analysis to recognize which message has been suppressed in future runs, and because it’s part of the source code the suppression is checked into source safe and easily recognized by others looking at the code.  In addition to the SuppressMessage method there is a SuppressMessageAttribute method which has the following signature:
        [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]

 

This example of that call is for a different message generated by migrating code from the Beta versions of VS2005 to the release version… in this case I want more time to investigate the implications of making the change suggested by the message to ensure that I eventually do this I can add a task to my TFS project, but that’s a story for another post.

Friday, November 11, 2005 1:32:19 PM (Pacific Standard Time, UTC-08:00)  #    Comments [0] -
.NET | Team System | Technology
# Wednesday, November 09, 2005

Back with Beta 2 it was found that Microsoft had set the refresh rate for the reports and data warehouse at 2 minutes.  The appropriate setting to avoid having your CPU thrash is about an hour.  As I explained in my May 2005 article this issue is more fully explained here: http://blogs.msdn.com/buckh/archive/2005/04/19/409886.aspx.

The Beta 3 Refresh of TFSMicrosoft resolved this issue.  In order to verify this I went to the service.  Note, under Beta 3 Refresh the controller service has moved slightly to this url: http://localhost:8080/Warehouse/v1.0/warehousecontroller.asmx.  Once at this url you need to access the 'GetNextInterval' method which accepts an integer.  Pass a 1 or 0 or whatever, and the service will return your servers updated interval value.  My experience is the current default is 3600 which is the correct value.

Wednesday, November 09, 2005 9:56:45 AM (Pacific Standard Time, UTC-08:00)  #    Comments [0] -
.NET | Team System | Technology
# Monday, November 07, 2005

So since the launch was today you've probably started the process of installing Visual Studio 2005 by now.  Hopefully you are also looking at leverageing Team Foundation Server (TFS).  In case you weren't aware the Beta 3 Refresh for TFS is also available.  This is the version of TFS which is compatible with the released version of VS2005.

Here at InterKnowlogy Lacie stood up TFS Beta 3 Refresh today and so we immediately tried to connect from VS2005 to our new TFS server.  That's when we realized we couldn't find the TFS Client in Visual Studio.  I had installed VS 2005 Team Suite so in theory I had everything but still we couldn't find Team Explorer.

In looking to the help, of course there was no indication of what the heck to do if you couldn't open the Team Explorer - no note saying - Hey Make sure you've also installed the TFS Client after your VS 2005 install!

With the release of VS2005 the TFS Client is no longer automatically installed, even if you install the full Team Suite.  Instead you need to separately install the client from the TFS CD on the client.  It took us a few minutes to realize this solution, so if you are standing up TFS be aware that each developer will need to have the TFS client installed.  While this makes it easier to separate the TFS Client Access Licenses from Visual Studio, it still would have been nice to know about the installation requirement.  BTW, this also makes it quite apparent that you don't need VS 2005 Team Suite in order to use TFS, just install the TFS on whichever version of Visual Studio 2005 you are using and you'll get the Team Explorer functionality (or even install it without VS 2005 for those non-developers on your project.)

Monday, November 07, 2005 4:46:59 PM (Pacific Standard Time, UTC-08:00)  #    Comments [0] -
.NET | Team System | Technology
# Sunday, October 30, 2005

Today Tim, Adam, Mike and I headed out for a ride.  We left from Tim's house just after first light and headed out into the Lake Calavera area.  We were headed over to the area we call Flightline (in the flight-path of Palomar Airport) and were headed up an access road on one of the farms out near Calavera.  This particular property has a lake up above the road and for some reason this year there is alot of ground water seeping out.

Well Mike had gotten a little ahead on the climb (because of an earlier mud patch that stopped Tim and I) when he hit the next mud patch.  Mike ran into a challenge and needed to put a foot down because the combination of climbing and mud meant he had stopped moving forward when this happened:

Yep, Mike's leg sank down past his knee in mud.  The picture above shows Tim headed up to help pull Mike out.  It's one of those classic moments that happens out on the trails.  The result was we all walked carefully through this section and afterwards I got this shot of Mike's leg covered in mud:

Fortunately Mike wasn't hurt, although I'm sure it wasn't the most pleasant experience moving forward for the remaining hour plus of riding. Just had to post this one since it's the first time we've ever managed to see it occur and of course how often will you sink past your knee in mud in Southern California before the start of rainy season? And yes that is the nice sticky mud that just doesn't want to wash off even in a stream (like the one at the crossing from Calavera to Flightline.   

The remaining question is did Mike just happen to step where a horse sank about two weeks earlier?  The reason I ask is that a week prior Adam and I came upon a couple horse riders who mentioned that they were avoiding the farm side of Calavera because the mud from some ground water made it so their horse sank up to it's knee the week before (two weeks back total).  Seems possible that Mike found the same spot the horse tried and since the horse had already loosened up a spot Mike was able to go right down in the same spot.

Of note however, I didn't think to take a picture of the new trail created to help cross between Calavera farms and Flightline.  There is an amazing new bridge over the second part of the stream and someone has cut the hillside to make a new scary but amazing trail.

Sunday, October 30, 2005 4:16:30 PM (Pacific Standard Time, UTC-08:00)  #    Comments [0] -
Cycling
# Saturday, October 29, 2005

Just as with a car, your bike (or in this case mine) requires routine maintaince.   Over time routine maintenance (keeping your chain clean and lubed) stops being enough.  My Mountain bike recently reached this point.  It started when the mechnanism in my rear hub started to not spin freely.  I needed a new rear wheel.  Unfortunately the first mechanic I took my bike to told me my problems weren't significant and all I needed to do was repair a broken spoke...  On my next ride out my rear wheel truly died - when I tried to pedal under stress the hub's inner workings were stripped and I went no where.

Well I spoke with the mechanic again and he said yep - you need a new rear wheel, plus my chain was worn as were both my front and rear chain rings.  I was going to need a new wheel and a new crankset - which he would have sold me, but I passed.  After all we're talking about a bike that cost me less than $400.  I searched for and found a good deal, getting a new pair of wheels (that are disc brake compatible - as is my frame) for about $50 (sales aligned and I got about 75% off the retail from this one store).  So I learned to disassemble my rear chain rings from the wheel and transitioned the wheel on my own, allowing me to continue - at least for one ride.

On that ride I snapped my chain - not the first time I've done this.  Replacing the remainder of my drivetrain started when I snapped my chain.  When I put a new chain on the bike I immediately started suffering from what is known as "Chain Suck". Chain suck is characterized by your chain remaining on your front chain ring as you pedal, so instead of it coming free at the bottom of your chain ring and feeding to the back wheel, the chain rides back up and runs into itself coming onto the top of the chain ring.  This stops your pedalling.  Chain suck normally occurs on your small front chain ring and accordingly mostly strikes when you are trying to climb.  It's a significant problem and since it started on my first ride with my new chain it meant I needed more work.

Recognizing that the problem was that my front chain rings were just too worn, I set out to replace them.  Did I need to purchase a whole new front crankset for like $200+?  No.

Fortunately I realized I didn't need to spend $200+ on a new crankset and instead could replace only the chain rings keeping my front cranks.  So instead of paying $200 for a new front crankset I paid $18 for a small chain ring and about $32 for a medium (middle) chain ring.  Throw in a new rear cassette for good measure at $40 and you are talking about rebuilding the key elements of my drive train from about $100 instead of $250 + labor.

So how worn were my components well here are some photos to compare the rings first up my old small front chain ring, then the reassemble crankset with small and medium rings and then the old medium chain ring:

Can you spot how warn my chain ring teeth were.  As you can tell I've been pushing my bike pretty hard and it shows on those rings.  I also replace my rear cassette and here is the reverse angle of my old and new rear cassette, again note how worn the old teeth are:

even though it's clean, you can see how worn the teeth are and how uneven the curves are in the old cassette above vs. the cassette below:

So all told I put in about $150 to rebuild the majority of the drive train elements on my bike.  Doing the work myself saved literally hundreds more in maintenance charges considering the going rate for a simple tune up in Southern California is $50.  The result my bike is once again operational and although I'm still hoping to one day pull down a beautiful full suspension bike (like everyone I ride with) for now my hard-tail is trail ready and I can continue to enjoy views like this one from the top of 2N71.

Saturday, October 29, 2005 4:04:21 PM (Pacific Daylight Time, UTC-07:00)  #    Comments [0] -
Cycling
Archive
<November 2005>
SunMonTueWedThuFriSat
303112345
6789101112
13141516171819
20212223242526
27282930123
45678910
About the author/Disclaimer

Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

© Copyright 2012
Bill Sheldon
Sign In
All Content © 2012, Bill Sheldon