The criteria we've come up for choosing a Static Code Analysis tool are the following:
Integration - how well does it integrate with VS2005. Does it claim to integrate with VS2008? What about legacy VS2003 stuff?
Versions - can it work against a .NET 1 project? Or a .NET 3/3.5 one?
Ease of use - how easy is it to run an analysis? How easy is it to understand what it wants you to fix? And where the code is?
Ease of configuration - how easy is it to add a new rule? Or turn one off?
Issue detection - running it against a specific project, what does it detect? How many potential issues does it spot? How does this compare the other tools?
Stability - any problems noticed since installing it/using it?
Extra - what else is there about this tool? Any added bonuses?
Is there anything else we should be thinking about?
Note: We've excluded cost as we're interested in finding the right tool without thinking about budgetary constraints.
One of my colleagues and I are looking into tools for Static Code Analysis for C#. At the moment, we have the following tools on our list to investigate further:
I have used both FXCop and NDepend. I found FXCop is great, although you need to spend a bit of time customising it for your own requirements. Not exactly a suggestion for other tools, but at least you know one other person has used (and likes) a couple of things on your list :).
My project involves several front end sites, all looking at one database and using one admin system and code base. If you login to one of the sites, you don't automatically get logged in to the others. So, I'm using a cookie name with a prefix based on the site name. One of my sites has an & in its name - something like A&BSite. When I attempt to login to this site, I get no errors but neither do I get logged in. The code works happily for all the other sites, so I can only assume that either .NET, or the browsers (tried on IE7 and firefox) don't appreciate my use of an &. I've just updated the code to SiteName.Replace("&","") and all is happy and jolly once more. Weird!
A quick straw poll around the office revealed that only one of the developers had come across this before.
Article - Don't ask employees to be passionate about the company!
There is an excellent article over at Creating Passionate Users, Don't ask employees to be passionate about the company! which examines the differences between people who have a passion for their employee and a passion for their work. I think I might involve the simple 4-question test into any interviews I do in the future as it is a good match to some of the questions I already ask ("Have you contributed any code or writings to the wider community").
When was the last time you read a trade/professional journal or book related to your work? (can substitute "attended an industry conference or took a course")
Name at least two of the key people in your field
If you had to, would you spend your own money to buy tools or other materials that would improve the quality of your work?
If you did not do this for work, would you still do it (or something related to it) as a hobby?
I've always been interested in recruiting team members with a passion for their trade, who are keen to learn and show their ability. Hopefully these questions will help me to achieve this in the future.
At home I use the eclipse development environment and so, after my introduction to Ruby on Rails on Saturday, I started reading up on RadRails, a Ruby on Rails IDE which plugs in to eclipse. Through reading up I discovered the eclipse SQL Explorer plugin, which (with a little help from Richard and from a tutorial) is now working on my mac and which looks like a great interface to many different databases.
Sometimes I forget how fortunate I am to live in a city which is so full of technical and new media focussed people. We have a vibrant community of technologists, both in the real world and in the online world.
Mainly online with occasional meetups:
Brighton Bloggers - obviously top of the list as I maintain it :-) It is A site listing all the bloggers in Brighton (that I know of) - currently running at 268 entries.
Brighton New Media - mailing list offering on topic and off topic conversations, covering topics from development, design through to tradesman recommendations. Be warned, its pretty busy!
Mainly meetups:
Sussex Geek Dinner - Simon organises the Geek Dinner for Sussex, and the last 3 or 4 have been based down in Brighton, offering speakers as well as conversation.
Brighton Girl Geek Dinner - In its infancy, but if the 1st event is anything to go by this could be a really successful venture.
Brighton Ruby - user group for Brighton Ruby developers
Brighton Farm - a networking group for web designers, developers and people with related new media skills who live in Brighton and the surrounding areas
Coding Dojo - in the two hour session, up to twelve developers take turns solving a programming problem
Hopefully SkillSwap will return as well in the near future to the benefit of all again.
I'm sure that this isn't a conclusive list, but it does go to show how much of a technical community there is down here. What a great place to live and geek :-)
I had a great day at WebDD today and attended some good sessions - which I'll go into more later. The Scott Guthrie sessions were hugely over-subscribed, but were recorded so I hope to get a chance to see them at a later stage. Initally not a lot of swag, but I got to leave with a copy of Expression Web as well as a pen and some magazines.
The sessions I attended today were:
Expression Web - an excellent introduction to a tool which looks great
And so there ends my first ever conference, I'm not sure why but I've never managed to attend one before. I'm definitely hoping to attend the next WebDD event, and also probably the DeveloperDeveloperDeveloper! events too.
WebDD tomorrow, and I'd read through all the sessions at the weekend and planned my schedule only to discover that it has been updated, and so my initial plan needs revisiting. Now I find that Glenn Jones clashes with Scott Guthrie :-( A re-plan is in progress...
The database for my current project stores pdf documents as images within the database. I needed to write a quick rough and ready program to retrieve all pdfs which meet a certain set of criteria.
The main key is remembering that a binary, or image comes back as an array of bytes. This enables us to make use of System.IO.File.WriteAllBytes which takes in a string parameter filePath representing the path to the file, and a byte[] parameter representing the file.
I set up a data set, and defined a TableAdapter MyQueryTableAdapter to have a parameterised query as MyQuery to extract the relevant fields, and then used:
MyProjectTableAdapters.MyQueryTableAdapter tableAdapter = new MyProject.MyProjectTableAdapters.MyQueryTableAdapter(); MyProject.MyQueryDataTable table;
to define table and tableAdapter variables. These were then used to populate the table with data based upon myParameter.
table = tableAdapter.GetData(myParameter);
All I did then was loop through the table.Rows in the table and populate a byte[] myPdfDocument variable for each row. This myPdfDocument was then written using the above code.
Last night was another Sussex Geek Dinner at the Black Horse in Brighton. Mikel Maron gave a very interesting and informative talk about OpenStreetMap. He covered the history, his involvement and, of course, Brighton's coverage. This is all of particular interest to me at the moment as I've just done my first snowboarding trip armed with a gps solution (although one with issues).
Our gps solution is a mobile phone application paired via bluetooth with a Globalsat BT338 x-trac bluetooth GPS receiver. This works reasonably well, but we've had issues with a) the client software only working on one of four available mobile phones and b) the web solution maps not working very well on a mac. All that said, it does allow export to google earth and looking at our snowboard runs overlaid on satellite imagery is quite satisfying.
I found myself with a bit of a challenge yesterday. I have a form which has client validation but also has a message displayed back from the server after a save.
When a save happens a "Update successful" message is displayed on the screen as an <asp:label>.
When the client side validation happens, then one of many error messages are displayed on the screen.
This means that both the "Update successful" and the error messages are displayed on the screen at the same time. This obviously isn't ideal and doesn't give the user a clear message.
For a while I was going to do this using a <asp:customvalidator> calling some javascript to clear out the label. And then I read "The custom validation subroutine is not called when the control being validated does not contain any data. The only control that you can use to check for an empty form field is the RequiredFieldValdiator control" which scuppered those plans.
I then did a bit of googling and discovered that I could use the Attributes property to get at the client side events of an element. So, a bit of code that does TextBox1.Attributes["onblur"] = "for(i=0; i<document.all.length; i++){if (document.all[i].id.indexOf('Label1') > -1) { var element = document.all[i];element.innerHTML='Changes have been made';};}"; works like a charm and when focus leaves TextBox1, the text in the element Label1 changes to be "Hello".
I then manipulated it a bit more and discovered that if in the html the Label1 element is set to visible="false", then the javascript fails due to the non-existance of that element.
So, the final result is:
The basic form:
When a required field is missing (note both the validator text and the change of text in the label caused by changing the focus):
When the two textboxes don't have identical content:
With asp code of: <asp:Label ID="Label1" runat="server" Text="Label">Please make some changes</asp:Label> <br /> <asp:TextBox ID="TextBox1" runat="server">TextBox1</asp:TextBox> <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="RequiredFieldValidator" ControlToValidate="TextBox1" Text="RequiredFieldValidator"></asp:RequiredFieldValidator> <br /> <asp:TextBox ID="TextBox2" runat="server">TextBox2</asp:TextBox> <asp:CompareValidator ID="CompareValidator1" runat="server" ErrorMessage="CompareValidator" ControlToCompare="TextBox2" ControlToValidate="TextBox1">CompareValidator</asp:CompareValidator><br/> <asp:Button ID="Button1" runat="server" Text="Button" />
and a code behind of protected void Page_Load(object sender, EventArgs e) { if (Label1.Visible) { TextBox1.Attributes["onblur"] = "for(i=0; i -1) { var element = document.all[i];element.innerHTML='Changes have been made';};}"; } }
Last night was the firstBrighton Girl Geek Dinner and most enjoyable it was as well. Great turnout, excellent organisation (name stickers, information sheet, guest book) and an interesting talk by Rose Luckin on Learner Centred Design, covering completed projects on homework and augmented reality, and touching on a new project vesel.
I had some interesting conversations ranging from photography, through process management, training needs, print versus web and the benefits of both and finally what kind of wings would be on Sophie's wellies.
Future Platforms hosted a text voting mechanism to vote for subjects we'd like to hear talked about at future events - everything got at least one vote, and the winners seemed to be in the game and social area as well as the future of technology.
Congratulations to Devi, Joh and Rosie (in alphabetic order) for a great night. I'm looking forward to the next one.
MSDN Virtual Lab: Express: What’s New in SQL Server 2005
I decided to take a look at the MSDN Virtual Labs after finding this a good way to work on my ASP.NET course. I figured I'd start off with the Express: What’s New in SQL Server 2005 lab and see how I got on. This was a 30 minute lab, and I've got quite a bit out of it.
I hadn't read anything about the new PIVOT and UNPIVOT functionality, and by following up on that I discovered about the introduction of Common Table Expressions which look like a much more elegant way of temporarily storing data for use within stored procedures etc. This should give a lot more flexibility.
The other thing I knew about but hadn't seen examples of was the TRY...CATCH functionality. This is a great addition, but it is a shame that it doesn't work with user defined functions as well.
I've registered to attend the WebDD event at Reading on February 3rd. Some of the sessions look really interesting.
I'm definitely planning to attend the "Ruby On Rails for .NET Developers" talk by Dave Verwer as Ruby is something I've been trying to find time to look at for a while now. I narrowly missed attending the Brighton Ruby user group meeting on Tuesday, but maybe by the next one I'll have learnt a bit more about it.
I'm also likely to pop along to the two sessions on "End to End Web Sites" by Scott Guthrie as they seem like a good comprehensive way to keep the content learnt at my recent courses fresh, especially the AJAX bits.
I went to Dave's talk at the last DDD, and it was truly brilliant. The slides were pretty, and he covered so much in so little time. Best talk of the day for me.
We visited some friends for a lovely roast dinner yesterday and whilst we were there I did some technical support. Since upgrading to IE7 Microsoft Live Messenger had stopped signing in saying there was a temporary service problem and displaying error code 80040111. We tried logging on via meebo.com and that worked well. After a bit of googling I discovered a two point plan. Firstly, re-register msxml.dll. This resulted in a different error code - this indicated progress. I googled for that code (can't remember what it was) and found a suggestion to remove Live Messenger, reinstall Live Messenger and reboot. I did all that, and it all worked. A fair exchange for a yummy dinner.
One of the Brighton Bloggers, Paul Silver, did some ground work on Google Co-op for me. He created us a Brighton Bloggers search, and added a load of sites to it and added me as a contributor. Unfortunately as a contributor I could only add sites, I couldn't see what had already been added, neither could I configure the look and feel. But, Paul assured me it was straightforward so today I gave it a go, and can now unveil the Brighton Bloggers Search page. I've added the 248 sites which we currently have registered on the site, and have added it to my list of things to do when adding new blogs to the list.
For some reason the markup returned from Google includes a vast amount of white space after the searches, and I haven't yet worked out why, despite rummaging through the documentation.
MS2543 - Core Web Application Technologies Course - Days 2 & 3 / MS2544 - Advanced Web Application Technologies - Days 1 & 2
It was quite a packed week, with lots of hints and tips gained as well as an insight into the way we can progress our web products to make the most of the .Net framework. We even had some spare time to take a look at ASP.NET Ajax which looks really handy.
Some of the most pertinent things to have come out of the course are things like session state management, specially with regards to the server farm environment - something we've had a problem with for a while.
The best thing for have come out of the course though was probably the opportunity to experiement, to try some things out and to work out how to integrate our learnings into our projects.
MS2543 - Core Web Application Technologies Course - Day 1
My team have been given a new project to work on, which is improvements to the current functionality offered by an ASP.NET 2/C# product. To this end, we've highlighted a couple of courses as a way to get up to speed to enable us to maintain and enhance this product going forward.
Yesterday was the first day of the course, and covered off several of the basics, covering the creation of a web application using a file system web server, doing some basic programming, handling errors nicely and also starting to look into using server controls and the use of postback.
So far I'm enjoying it, and its starting to make the source code that I looked at last week for the new product far easier to understand. My last forray into web development using Microsoft tools was back in 2003 when I last did some ASP work. I'm hoping to be able to lead by example and do some development as well as recommendations and design work.
After my success at getting the booklistrunning off del.icio.us tags I thought that it might be time to do something similar with my list of snowboard resorts. So with some quick new tag additions of "riddenat" and "torideat" along with country tags I've got a list of mountains I've boarded at, and mountains I plan to board at. I love del.icio.us tags.
I listened to an excellent IT Conversations podcast this morning - What Teens Want. Taken from the Web 2.0 2005 conference, it featured a panel of teenagers answering questions on their internet habits, what sites they spent lots of time on (myspace, facebook), how they chatted with their friends (AIM mainly) and how they found music. Really interesting to hear what 17-18 year olds see as important - their prime concern seems to be what can they get for free, although at least one of them is happy to spend $50 - $60 per month on ring tones for his phone.
I did some more tinkering last night, and changed the Reading page. On del.icio.us I've set up some tags to indicate things (primarily books) that I've read or am currently reading. In addition I've also got a set of articles and books to read.
I started off finding the html links and so used the object tag to reference the html. <object data="http://del.icio.us/html/Ull/reading?tags=no&extended=body&rssbutton=no"></object> which produces
and of course by introducing height and width tags it can be made to look a lot better
This was a good start, but I wanted to have my styling used, rather than the browser default styling. So, I had another hunt around the del.icio.us help and found a page about linkrolls which seemed to do 95% of what I wanted.
So, with a bit of javascript code <script type="text/javascript" src="http://del.icio.us/feeds/js/Ull/reading?extended?extended;bullet=%E2%80%A2"></script> I get to display the most recent links saved to the reading tag in my list of del.icio.us bookmarks. Using this method I get to supplement my current styles with those provided through the styling. Some day I may try and change it to get the extra 5% of functionality I wanted but this is good enough for now.
This is the third incarnation of a book list, but this is by far the simplest and easiest to maintain - the original set of reviews is still active over at janeandrichard.co.uk.
There's an excellent article on the effect of task switching over at coding horror. As the leader of a small (4-5 people) team I spend most of my time task-switching, between doing management activities, supporting our existing products, planning future activities, reviewing designs or code with the team not to mention the odd bit of development or technical investigations that still come my way. There's little wonder that I go home most nights wondering if I've actually achieved anything at all that day. As a team we develop and maintain a large number of related products, and have recently been given assurance that our current main project focus is one of the most important to the company. And yet, I still find extra bits and pieces of work being pushed into the team to work on, "it won't take up too much time and then you can focus on the main project", because our customers (external) have been promised something, or it's really important etc. I'm planning to print this graph out, laminate it and carry it to meetings just in case the "can you just" or "I've got something that I need your team to look at" sentences begin...
Last weekend I added a "Add to del.icio.us" link to the bottom of all posts both on this blog, and on Brighton Bloggers.
I made use of 3spots: 30 Social Bookmarks 'Add to' footer links for blogs to get the scripts I needed and combined it with the del.icio.us script. I then made use of the image that they've used on that page. I didn't really want to have another text link at the bottom of each post, so this suits me just fine. I figured that anyone using del.icio.us will recognise the graphic.
I like the idea of emotional gadgets, things that let you know when other people are thinking about you, or things that are just fun to have around. The nabaztag bunny is just such a thing but the £72 price tag is quite steep for something that is just a cute gadget. But last weekend I read Tom's blog and he's found a business justification for having one. So, its obviously time to get my thinking cap on and start finding more practical uses for a nabaztag.
I've been having problems with deadlock on SSIS variables. The main issue is that I have a script item, which has a readwrite variable of strErrorDescription. In the case of a problem this gets populated. I have an onError event tied to this script item. That event uses strErrorDescription to populate the reason for the error. The onError event triggers before the script item finishes properly, and so before the variable gets released. After a bit of headscratching I found this post on the MSDN forums which describes the problem, and a workaround. I've added Dts.Variables.Unlock() to the code, just after the variable is written to, and this seems to do the trick.
I was struggling to find a way to debug event handler scripts in SSIS, and thought I was missing something obvious (as did Jamie). Thanks to Daniel Read (again) I now know that I'm not the only one:
b) Cannot debug script tasks in event handlers. This appears to be a bug. I can't get the debugger to stop on a line of code in a script task in an event handler. Strangely, if I set a break point in a script task in an event handler, a VBA code window will pop up for the first script task in the package (even though the breakpoint is not set in that task), but there will never be a break in the task where I set my breakpoint
As mentioned before, I didn't make it to this years d.construct, hopefully next year. Andy has written an excellent debrief on the event from an organisers perspective, which is quite interesting reading and a change from the attendees perspective that I've mainly been reading. There is a wide variety of material out there, from videos and photos, through presentation slides and the podcasts which are apparently coming soon.
I've been running our usual deployment scripts against a SQL 2005 database to see what the damage was. Not too bad as it turns out, 2 procedures which used alias.columnname in the ORDER BY clause, 2 logons where the password wasn't secure enough, and 2 DTS packages which aren't deployed due to : SQL Server blocked access to procedure 'sys.sp_OACreate' of component 'Ole Automation Procedures' because this component is turned off as part of the security configuration for this server. A system administrator can enable the use of 'Ole Automation Procedures' by using sp_configure. For more information about enabling 'Ole Automation Procedures', see "Surface Area Configuration" in SQL Server Books Online.
I want to use sp_configure to achieve this, as our product is deployed mainly automatically, including the database scripts. Most of the help I could find revolved around the SQL Server Surface Area Configuration and using either the SQL Server 2005 Surface Area Configuration tool or even the command line sac Utility. I decided to initially take a look at the tool to get an idea, and on investigation, the option I need falls under Surface Area Configuration for Features and is listed under OLE Automation. After a bit more digging, I found that the sp_configure option is Ole Automation Procedures and so the code is: EXEC sp_configure 'Ole Automation Procedures'; GO but this results in the following: Msg 15123, Level 16, State 1, Procedure sp_configure, Line 51 The configuration option 'Ole Automation Procedures' does not exist, or it may be an advanced option. and so needs to be paired with the Show Advanced Options setting, and so the following is required: sp_configure 'show advanced options', 1; GO RECONFIGURE; GO sp_configure 'Ole Automation Procedures', 1; GO RECONFIGURE; GO This results in the following: Configuration option 'show advanced options' changed from 0 to 1. Run the RECONFIGURE statement to install. Configuration option 'Ole Automation Procedures' changed from 0 to 1. Run the RECONFIGURE statement to install. and when I re-run the deployment scripts I get no errors. Hurrah!
taras_96 that's an interesting question, and after a bit of searching I believe it should be allowed.
The MSDN article for "ORDER BY Clause (Transact-SQL)" (http://msdn2.microsoft.com/en-us/library/ms188385.aspx) states amongst the definition for order_by_expression that
"Column names and aliases can be qualified by the table or view name."
which would imply that that warning/error is invalid.