Plunging into .NET Development

Weblog Pieter Gheysens
Microsoft .NET Development - C# - Enterprise Library - Visual Studio 2005 Team System - Compuware DevPartner - ...
 


Tuesday, December 28

JumpStart DevPartner Studio Pro [2]

In one of my previous posts I've talked already about Performance Analysis. Let's focus now on Code Analysis/Review for this post ...

DevPartner Code Review

DevPartner identifies .NET programming [VB.NET and C#] and naming violations, analyzes method call structures and tracks overall code complexity. Before starting with a static code review, you should have defined the rule set for your solution. DevPartner contains an extensible rules database (600+) that is based on the Microsoft Visual Studio programming standards. The rules database is maintained and stored in the Rule Manager [standalone application].



Recommandations for your code-review :
  • Code review as from the start
    Try to make use of code review (especially naming conventions) when you start your project. As every good developer knows or should know : delaying/postponing the application of good practices is NOT the way to go because at a certain point in the development phase you will be trapped and you will be kicking yourself that you didn't do it from the beginning. Afterwards, the job becomes very time-consuming and it's not the most attractive thing to do.


  • Involve each developer
    Reviewing code of your team-members and vice versa is more productive than reviewing your own code. Each developer can be made responsible for a certain project in your solution. DevPartner lets you select the separate projects you want to include for your code review. Uncheck the redundant projects because a code review of a large solution with many projects can take some time!




  • Suppress rules only when needed
    Do not suppress rules to click your problems away. Think about the usefulness of the rule for your project before you decide to suppress it. Some rules can have no importance at the start, but can become more important (for performance reasons for example) as the project grows.
DevPartner lets you also execute a command line batch review of your solution in conjunction with a nightly build or as an alternative to reviewing large applications. Customizing rules in DevPartner is possible with good knowledge of regular expressions.

Do not underestimate the power of good coding practices if you are seeking for quality software! To be effective, each developer must stick to the same coding standards and naming guidelines.

Useful Links

Saturday, December 25

Microsoft Top 10 Challenges for 2005

Directions on Microsoft has published the Top 10 challenges for next year and beyond.
  1. Where Does Microsoft Want to Go Today?
  2. Acquisitions That Help
  3. Security, Security, Security
  4. Make the PC the Home Entertainment Hub
  5. Maintenance: Value for the Money
  6. Put a Lid on Open Source
  7. Win Over Developers with Longhorn
  8. Turn the Corner with Xbox 2
  9. When I'm 64
  10. Play Well with Others
Read details here.

For developers in 2005, the release of Visual Studio 2005 (Whidbey) and SQL Server 2005 (Yukon) will be very important. Longhorn is still far away and will certainly come back in the Top 10 list for 2006, 2007, ...

Thursday, December 23

Hotmail vs GMail

I'm using Gmail (Beta) now for a couple of months. I'm not only very pleased by the storage capacity they offer [1 GigaByte !!], but also with the way how they handle messages that have the same context. You can compare it in a certain way with threads in newsgroups. In your mailbox it's now very easy to follow a conversation you've set up with different people.

At first sight I found it annoying that it was not possible to create separate folders to store your Gmail. Instead Gmail offered a labeling system. Now I must say that labels are actually better than separate folders because you can assign different labels to one single message. Not bad for organizing your mail. Gmail-notifier and Gmail-Drive make the whole package even more attractive!

I still use my hotmail-account for instant messaging (Messenger), but that's almost it. Today I've noticed that my hotmail-account was upgraded to store 250MB, but that won't make me switch to hotmail again for free web-based email. I ask myself the question how long Gmail will keep their mail-service "by invitation"?

Wednesday, December 22

JumpStart DevPartner Studio Pro

Yesterday I gave a little demo about DevPartner for my colleagues @ Compuware. Afterwards we talked a bit about the usage of the product and it seemed that some features were not yet discovered by some of the people who attended the session. It might be interesting to share some best practices for those people who are (or will be) working with DevPartner. Everyone who's interested in the product can download an evaluation version at http://nashua.compuware.com/evaluations/

First of all, let me summarize the capabilities of DevPartner Studio Professional : DevPartner Studio provides a variety of programmer productivity features, such as performance profiling, memory analysis, source code analysis, automated error detection, Web and distributed application analysis, and code coverage analysis. DevPartner Studio is a single application that fully integrates with the Visual Studio .NET IDE that provides access to all Functionality.

In this post, I will try to cover some best practices for Performance Analysis.

Performance Analysis

When you run your application during a performance analysis session, DevPartner collects performance data for source files, assemblies, methods, functions and individual lines of code. Results are displayed in the Visual Studio .NET IDE.
  • Exclude system images [Source 100%]

    By default this option is unchecked [Tools > DevPartner > Options ...] and as a result DevPartner collects all system-operations during the run. You should check this option to analyze only your source-code. Otherwise your performance runs will take much longer (really annoying if you are running large applications) and the results won't give you more interesting information about your methods/procedures.


  • Set display options

    Adjust the precision and scale [Tools > DevPartner > Options ...] if necessary.


  • Make use of DevPartner sessions (snapshots)

    During a run you can clear at any time all collected data to the point which the Clear action executes. This feature is really interesting if you want to focus on the performance of a specific action. You can even set a normal breakpoint in your code to clear all data that was gathered before that breakpoint. Data collection then starts from zero after your breakpoint.


  • Display your results in the right format

    Check desired columns and uncheck redundant columns in the result-view.
Remember that the most important thing is not to gather your data, but to analyze/interpret your data. You should learn how you can boost performance in general for your applications. DevPartner lets you drilldown to the true bottlenecks in your applications. Most of the time, low performance will be caused by data-operations : getting data from your database. Limit database-calls, try to process batch-sql-calls where applicable and optimize your stored procedures and/or sql statements. Caching in your application is also a solution for decreasing the number of calls to your database. In my recent project for example, custom caching of data objects into hashtables made a big performance improvement for time-consuming calculations.

In my upcoming post, I'll tackle some other capabilities of DevParnter Studio Professional.

Monday, December 20

Number of Microsoft Certified Professionals Worldwide

I knew there existed an overview of this, but now I found it back on the Microsoft Learning Website.

I must hurry up when I want to become one of the first 10 000 MCSDs .NET Worldwide. I still need to pass the last exam : Analyzing Requirements and Defining Microsoft .NET Solution Architectures. One thing for sure : it won't happen anymore in 2004 ;-(

I wonder how many MCSDs .NET there are already in Belgium? Anyone an idea?
 

Friday, December 17

Usernames and passwords replaced by your finger

Did you ever 4get usernames and/or passwords for logging in to a website? Well, I did and even more than once ...

Eliminate username and password hassles! Log on to your computer or to websites with your fingerprint. Check out the Microsoft Fingerprint Reader Products. The demo on the site looks quite cool ;-)

A present/gadget for under the Christmas-tree?

Thursday, December 16

Customizing System.Windows.Forms.ListView

In the beginning I wasn't really excited about using ListViews for my GUI, but nowadays I found them quite useful because they have more GUI-power than I was aware of, but they still have their limitations.

Some months ago, during Euro 2004 in Portugal [Yes, I am a soccer-fan], I was building a small tool to follow the tournament (see picture).

How to customize ListViews ...
  • How to make use of images
    First of all, you must create an ImageList with your chosen images. The ListView-control can display icons from three sorts of ImageLists [LargeImageList, SmallImageList and StateImageList], dependent on how you want to present your ListView.
    • The LargeImageList is set for the "LargeIcon" View of the ListView.
    • The SmallImageList is set for the "List", "Details" and "SmallIcon" view of the ListView.
    • The StateImageList is used when an additional set of icons needs to be displayed (by default a checkbox).

    In my example I have chosen to work with the SmallImageList.

    //Assign ImageList to SmallImageList-property of ListView
    this.MylistViewGroup.SmallImageList = this.imageListGroupA;

  • Creation of ListViewItem
    For each row you want to add to the ListView, you must create a ListViewItem ...

    //The constructor also defines the textValue for the first ColumnValue
    ListViewItem myListViewItem = new ListViewItem("");
    //Set ImageIndex for ListViewItem
    myListViewItem.ImageIndex = 0; //0 is the index for the image of Spain

  • Make it possible to format the ListViewSubItem
    You must set the ListViewItem-property "UseItetmStyleForSubItems" to false before the formatting of the SubItems will be displayed on screen.

    //Style for ListViewItem is not used for all SubItems
    myListViewItem.UseItemStyleForSubItems = false;

  • Create ListViewSubItems and add them to the ListViewItem
    For each column you should create a ListViewSubItem (with formatting if needed) and add this in the desired order to the ListViewItem [starting with the second column because the first column is already set via the constructor of the ListViewItem].

    //Create ListViewSubItem
    ListViewItem.ListViewSubItem lvSubItemColumn2 = new ListViewItem.ListViewSubItem();
    //Assign text for the ColumnValue
    lvSubItemColumn2.Text = "Portugal";
    //Assign ForeColor and BackColor. You can also specify a new Font if necessary
    lvSubItemColumn2.ForeColor = System.Drawing.Color.Black;
    lvSubItemColumn2.BackColor = System.Drawing.Color.WhiteSmoke;
    //Adding subItem to listViewItem
    myListViewItem.SubItems.Add(lvSubItemColumn2);
    //Add other SubItems to ListViewItem
    ...

  • Add ListViewItem to ListView
    At the end when all subItems are added to the different ListViewItems, add all ListViewItems to the ListView.

    //Add created ListViewItem to ListView
    this.MylistViewGroup.Items.Add(myListViewItem);

A real shortcoming of the ListView-control is that the image for the ListViewItem is always placed (by default) in the first column of the ListView and there is no property to change that. This means that you cannot place an image in another column and as a result you can have maximum 2 images for each ListViewItem in the same column when using the StateImageList.

The standard ListView-control supports multiple columns, which can hold unique text values. In many circumstances that simplicity is enough, but sometimes the need will arise to embed something other than text in a ListView's column. Anyone already familiar with those kind of things? Custom Controls?

Tuesday, December 14

About this.Blog.Owner

Hello,

My name is Pieter Gheysens and I work as a .NET Consultant for Compuware Belgium. I studied Applied Economics at the University of Leuven and obtained an extra degree in Management Informatics. After my student-years I joined the Professional Services Division at Compuware in August Y2K.

My goal was to start blogging in 2005 ... We aren't there yet but hey - here I am already! Setting up this blog was really not so hard. Just some changes to the template and uploading a picture! Plug and play!

In my blog I will try to share my experiences about .NET Development [C#], especially Windows Forms. Compuware has also a set of products that are related to .NET development. In my projects I've worked already with DevPartner. DevPartner Studio Professional Edition pinpoints coding errors, measures runtime performance and provides complete test coverage. Its features are tightly integrated with Visual Studio .NET, helping you build reliable, high-performing code consistently across distributed environments. More about this tool will follow!

Feel free to comment on my posts. If you have questions about a particular topic, you can always drop me a mail at my emailAddress ...

string firstName = "Pieter";
string lastName = "Gheysens";
string emailAddress = firstName + "." + lastName + "@gmail.com";

Disclaimer
All statements expressed in my blog are solely my own and are not necessarily in line with those of my employer.

Update : I decided to leave Compuware in 2009 and started my own company Sparkles to focus entirely on Application Lifecycle Management with Visual Studio Team System and Team Foundation Server. Since April 2009, I've been rewarded with the MVP Team System award.