Here's a good article on how to do comments and tasks inside Visual Studio.  There are a lot of good tips in there, definitely a good read.

I figure I would share this as I’ve been having a heck of a time adding the NUnit test framework to ASP.NET MVC project in VS2008 Professional.  I’m running Windows 7 RTM 64-bit and most of the examples on the web don’t take into account the differences associated with a 64-bit OS.  So keep in mind this template is for a 64-bit OS, specifically Windows 7. 

To start, the path in the registry where the NUnit entries need to get added is:

HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\VisualStudio\9.0\MVC\TestProjectTemplates\NUnit\C#

Also, the template zip file needs to get copied to the following folder:

C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\IDE\ProjectTemplates\CSharp\Test\1033

A lot of people instruct people to place it one directory above the one I listed, which wouldn’t work for some reason.  I zipped everything up so just download the zip file, unzip it, and run the regnunittomvc.bat to install.  Also keep in mind that this will work with any version of NUnit.  I just installed this with NUnit 2.5.2.9222 and it worked beautifully.  I also included Rhino.Mocks with this template also (version 3.6).  Enjoy.

 

image image
   
drohm, Tue 08/25/09 07:08 AM

I just reformatted one of my boxes at home here where I run IIS, SQL Server 2008, host my subversion repositories, and CruiseControl.NET.  I upgraded the OS on this box from Vista Ultimate SP1 to Windows 7 Ultimate RTM.  During the process of reinstalling all of my apps, development tools and reconfiguring those tools I ran into the problem of getting CC.NET to work under IIS 7.  One of the issues I had was that the virtual directory that the CC.NET installer creates was not getting created.  I then manually created the virtual directory and pointed it to the webdashboard directory where CC.NET was installed.  This didn't work either.  After doing some searching I found that the virtual directory needs to have the "Classic .NET AppPool" application pool in order for it to work propertly.  After I made that change I got a little further but received this error when trying to view the project web page:

Server Error
--------------------------------------------------------------------------------
HTTP Error 404.11 – URL_DOUBLE_ESCAPED
HRESULT: 0
Description of HRESULT # The operation completed successfully.

I found a Microsoft KB article that describes the problem and how to fix it, offering several ways to get around it.  The option I chose was to open a command prompt and issue the following command:

Appcmd set config "Default Web Site" /section:system.webServer/Security/requestFiltering -allowDoubleEscaping:True

I then reset IIS and boom, all was running properly.  Hope this helps anyone encountering these problems trying to get CC.NET running on IIS 7.

Steve Dunn recently released a new version of his Windows Live Writer plugin that allows you to insert code into your blog posts that properly formats and highlights everything.  It’s customizable and easy to use with a plethora of options.  This is by far the best code formatter for Live Writer out there.  And best of all, its FREE!  Here are a few samples of the different formats you can use:

Highlighted code:

        /// <summary>
        /// Retrieves all articles.
        /// </summary>
        public override List<ArticleDetails> GetArticles(int pageIndex, int pageSize)
        {
            List<ArticleDetails> articles = new List<ArticleDetails>();
            using (SqlConnection cn = new SqlConnection(this.ConnectionString))

 

Formatted code:

        /// <summary>
        /// Retrieves all articles.
        /// </summary>
        public override List<ArticleDetails> GetArticles(int pageIndex, int pageSize)
        {
            List<ArticleDetails> articles = new List<ArticleDetails>();
            using (SqlConnection cn = new SqlConnection(this.ConnectionString))

 

Code as bitmap:

 

This is a great tool – you can download the plugin here.  Enjoy!

drohm, Wed 03/26/08 02:24 PM
Have you ever had someone ask you what Agile is and how it can help a development team or project?  Even worse, what if that person were your boss or stakeholder?  Mike Cottmeyer does a great job of explaining it in under 30 seconds.  Nicely said.

I just finished reading this book and thought I'd give a quick overview of it and my feelings on the book.

Quite simply, I loved the book. This was my first exposure to the ICONIX Process (created by Doug Rosenberg) and I would love to try to put this process in action on a future project. It's logical, systematical, and easy to learn. The real challenge is in sequence diagramming. The authors are very good at explaining the topic in a very easy-to-read and engaging style. The entire ICONIX process is discussed from beginning to end while implementing a Java/Spring bookstore web site.

ICONIX is considered an agile methodology. Taken right from the book: "ICONIX Process is a minimalist, streamlined approach that focuses on that area that lies in between use cases and code. Its emphasis is on what needs to happen at that point in the life cycle where you're starting out: you have a start on some use cases, and now you need to do good analysis and design." ICONIX originated several years before the UML and combined the best techniques from the "Three Amigos" (Ivar Jacabson, Jim Rumbaugh, and Grady Booch). The three methods, Ivar Jacobson's Objectory method, Jim Rumbaugh's Object Modeling Technique, and Grady Booch's 'Booch method', were combined by taking the best features of each method and integrating them into a lifecycle approach. The three UML modeling techniques used are Use Cases, Robustness Diagrams, and Sequence Diagrams. Robustness diagrams are a nice tool that helps bridge the gap for designers to get from Use Case's to Sequence Diagrams (from analysis to design).

Each chapter in the book starts out with a graphic (like the one listed above) of the area you're currently in printed in red. This helps the reader know exactly where they are in the process. Every chapter also gives a "Top 10 Guidelines" list for the topic and explains each point in detail throughout the chapter. At the end of each chapter there are exercises and practice problems to help to reinforce the topic just covered.  Also at the end of each chapter is a flow chart that shows the current step in the process in detail.  This summarizes the chapter by showing each sub-step in the process, which I found quite informative. The example used throughout the book is an internet bookstore and the authors explain 2-3 use cases from chapter to chapter. This allows you to see first-hand how a requirement becomes a use case and a domain model, then a robustness diagram with an updated domain model, which then leads to a detailed sequence diagram and a full-blown class diagram, which then easily transitions to real code. Thats what I really like most about the ICONIX process. The concepts are not new, they just follow a logical flow from requirements to code in the fastest way possible, losing most, if not all, ambiguity and vagueness of the system. What a novel concept!

The book is very well written with few mistakes (code or grammar). The authors go through each topic with an in-depth explanation and offer advice at every turn. Another nice tidbit I really enjoyed is in the chapter on Sequence diagramming, the authors list several quality OOAD books for further reading. For example, Object Design: Roles, Responsibilities, and Collaboration, which I'm now currently reading. Another book they mention for further reading is Object-Oriented Analysis and Design with Applications (the 3rd edition for this book just came out).

The book uses Enterprise Architect from Sparx Systems as the main modeling tool during the book. They also use MDG Integration for Visual Studio 2005 in Chapter 10 - Implementation: Getting From Detailed Design to Code and also in Chapter 11 - Code Review and Model Update to keep the code and design diagrams in sync.

If you're interested at all with software methodologies and processes, I highly recommend this book.

drohm, Wed 03/21/07 02:48 PM

A new version of VisualSVN was released yesterday packing a whole load of new features, the most significant being status icons for files and folders in Solution Explorer.  This new version is built against Subversion 1.4.0 and TortoiseSVN 1.4.1.7992.  Be sure to download both before installing this version.  Here is a list of the new features:

  • Status icons for files and folders in Solution Explorer.
  • Transparent deletion of files and folders from Subversion when Visual Studio removes them from disk.
  • New commands Checkout, Branch, Switch.
  • Evaluation license is valid for all users.
  • Several bug fixes and usability improvements.

Here is a screenshot of my Solution Explorer showing the new status icons:

In the options, you have a choice between 'traffic lights' status icons or 'high contrast' status icons.  I prefer the 'traffic lights' status icons (the ones in the screenshot above).  Enjoy.

Finally, a good Visual Studio add-in for subversion, VisualSVN.  I just found out about this plugin yesterday and so far have been using it without any problems or issues. It integrates with Visual Studio and uses TortoiseSVN to perform its actions. It also creates a new menu to access all of the Tortoise functions.  When you invoke any of the actions it creates a new Tortoise screen as a modal window over Visual Studio.  Here is a quick screenshot:

You can use the fully functional demo version free for 30 days.  After that, you can register it for a measly $19.  It's well worth the money in my opionion. I highly recommend this plugin for anyone doing .NET development with subversion as your source control repository.

Scott Hanselman just released a new and improved list of tools for developers and power users:

Scott Hanselman's 2006 Ultimate Developer and Power Users Tool List for Windows

If you've seen his previous lists, this one won't disappoint.  I'm always guaranteed to fine a gem or two here.  I have to admit that its satisfying to see another CodeRush fan.  If you're a geek, power user or developer, go check it out.  There are tools in his updated list you didn't know you needed until you saw them.  Definitely worth the read!

drohm, Tue 08/29/06 02:18 AM

About a month ago I used one of the new features built into .NET 2.0 and didn't realize its power until just yesterday after reading an MSDN article by Ken Getz and then a blog post by Chad Finsterwald. When I first used Predicates I knew it was something that helped my code look 'cleaner' but not to the degree I found yesterday. In case you're not familiar with Predicates, they are new to .NET 2.0 and are used by collections such as Array and List to perform methods such as RemoveAll, Find, FindAll, Exists, etc.  As the MSDN documentation points out, a predicate is a delegate.  As long as the method signatures are the same then any method that conforms to the signature of the Predicate can be called in its place.  The biggest benefits of using Predicates is that they allow your code to be more expressive and promote code reuse.

I'll explain how I was using predicates initially and then show how I improved the design.  In my web application, I'm using a LookupManager class that looks up items in a database.  One of the uses for this class is to get items for say, a state dropdown control.  Each item in the state list has an Id that is reflected in the database.  In my case, I'm using Guid's as the primary key.  I don't want to insert Guid's as the value for each ListItem in the aspx page, so I'm masking those Id's.  In order for me to search the list from a postback so that I can map the MaskedId back to the original Id, I need to make use of the List's Find method.  This is where predicates help make my code cleaner.

Here is my initial implementation:

        public LookupItem GetItem(LookupType type, IdentityField id)

        {

            _searchLookupItemId = id;

            List<LookupItem> items = Lookup(type);

            LookupItem foundItem = new LookupItem();

            foundItem = items.Find(LookupItemMatchById);

 

            return foundItem;

        }

 

        public LookupItem GetItem(LookupType type, int maskedId)

        {

            _searchLookupItemMaskedId = maskedId;

            List<LookupItem> items = Lookup(type);

            LookupItem foundItem = new LookupItem();

            foundItem = items.Find(LookupItemMatchByMaskedId);

 

            return foundItem;

        }

These two methods allow me to search the List by either the Id or MaskedId.  Each one calls the List's Find method, passing in the predicate method.  Here are those methods:

        #region LookupItemMatchById(LookupItem searchItem)

        /// <summary>

        /// Predicate that finds the <see cref="DougRohm.Solid.Domain.LookupItem"/> by matching Id's.

        /// </summary>

        /// <param name="searchItem">Item to search.</param>

        /// <returns>Boolean indicating if a match was found.</returns>

        private bool LookupItemMatchById(LookupItem searchItem)

        {

            if (searchItem.Id.Value.Equals(_Id))

            {

                return true;

            }

 

            return false;

        }

        #endregion

 

        #region LookupItemMatchByMaskedId(LookupItem searchItem)

        /// <summary>

        /// Predicate that finds the <see cref="DougRohm.Solid.Domain.LookupItem"/> by matching MaskedId's.

        /// </summary>

        /// <param name="searchItem">Item to search.</param>

        /// <returns>Boolean value indicating if a match was found.</returns>

        private bool LookupItemMatchByMaskedId(LookupItem searchItem)

        {

            if (searchItem.MaskedId.Equals(_MaskedId))

            {

                return true;

            }

 

            return false;

        }

        #endregion

One thing to note here.  In each GetItem method above, I'm setting member variables that tell each predicate what to search for.  This is one of the limitations to predicates - you can't pass parameters to them.  Using member variable is a way to get around this.  The main problem with that is that it clutters up the LookupManager class.  Not only is the class cluttered with the predicates themselves, but now I'm adding more member variables. Afterall, what does the LookupManager class have to do with Finding items based on Id's or MaskedId's?  Too much noise.

The ultimate solution to this is to wrap those member variables and the predicates themselves into its own class.  This allows for even greater code reuse and simplifies the LookupManager class at the same time.  Here is my final solution:

    /// <summary>

    /// Custom predicate class used to search a <see cref="DougRohm.Solid.Domain.LookupItem"/> collection

    /// by either it's Id or MaskedId.

    /// </summary>

    public class LookupItemIdMatch

    {

        #region Fields

 

        private IdentityField _Id;

        private int _MaskedId;

 

        #endregion

 

        #region Properties

 

        public IdentityField Id

        {

            get { return _Id; }

            set { _Id = value; }

        }

 

        public int MaskedId

        {

            get { return _MaskedId; }

            set { _MaskedId = value; }

        }

 

        public Predicate<LookupItem> MatchId

        {

            get { return LookupItemMatchById; }

        }

 

        public Predicate<LookupItem> MatchMaskedId

        {

            get { return LookupItemMatchByMaskedId; }

        }

 

        #endregion

 

        #region Constructors

 

        public LookupItemIdMatch(IdentityField id)

        {

            _Id = id;

        }

 

        public LookupItemIdMatch(int maskedId)

        {

            _MaskedId = maskedId;

        }

 

        #endregion

 

        #region Predicates

 

        #region LookupItemMatchById(LookupItem searchItem)

        /// <summary>

        /// Predicate that finds the <see cref="DougRohm.Solid.Domain.LookupItem"/> by matching Id's.

        /// </summary>

        /// <param name="searchItem">Item to search.</param>

        /// <returns>Boolean indicating if a match was found.</returns>

        private bool LookupItemMatchById(LookupItem searchItem)

        {

            if (searchItem.Id.Value.Equals(_Id))

            {

                return true;

            }

 

            return false;

        }

        #endregion

 

        #region LookupItemMatchByMaskedId(LookupItem searchItem)

        /// <summary>

        /// Predicate that finds the <see cref="DougRohm.Solid.Domain.LookupItem"/> by matching MaskedId's.

        /// </summary>

        /// <param name="searchItem">Item to search.</param>

        /// <returns>Boolean value indicating if a match was found.</returns>

        private bool LookupItemMatchByMaskedId(LookupItem searchItem)

        {

            if (searchItem.MaskedId.Equals(_MaskedId))

            {

                return true;

            }

 

            return false;

        }

        #endregion

 

        #endregion

    }

There are two constructors to the class, one that takes an IdentityField and one that takes an int.  I can instantiate this class with the appropriate Id that I plan to use.  Also, there are two properties that return predicates, MatchId and MatchMaskedId.  Each property returns the appropriate internal predicate for use in external code. To use this new class back in my LookupManager class in the GetItem methods I simply 'new' up an instance of this class:

        #region GetItem(LookupType type, IdentityField id)

        /// <summary>

        /// Gets a <see cref="DougRohm.Solid.Domain.LookupItem"/> based on the Id.

        /// </summary>

        /// <param name="type">A <see cref="DougRohm.Solid.BLL.LookupType" /> for the search.</param>

        /// <param name="id">The <see cref="DougRohm.Solid.Domain.LookupItem.Id"/> for the search.</param>

        /// <returns>Returns a <see cref="DougRohm.Solid.Domain.LookupItem"/>.</returns>

        public LookupItem GetItem(LookupType type, IdentityField id)

        {

            List<LookupItem> items = Lookup(type);

            LookupItem foundItem = new LookupItem();

            foundItem = items.Find(new LookupItemIdMatch(id).MatchId);

 

            return foundItem;

        }

        #endregion

 

        #region GetItem(LookupType type, int maskedId)

        /// <summary>

        /// Gets a <see cref="DougRohm.Solid.Domain.LookupItem"/> based on the Masked Id.

        /// </summary>

        /// <param name="type">A <see cref="DougRohm.Solid.BLL.LookupType" /> for the search.</param>

        /// <param name="maskedId">The <see cref="DougRohm.Solid.Domain.LookupItem.MaskedId"/> for the search.</param>

        /// <returns>Returns a <see cref="DougRohm.Solid.Domain.LookupItem"/>.</returns>

        public LookupItem GetItem(LookupType type, int maskedId)

        {

            List<LookupItem> items = Lookup(type);

            LookupItem foundItem = new LookupItem();

            foundItem = items.Find(new LookupItemIdMatch(maskedId).MatchMaskedId);

 

            return foundItem;

        }

        #endregion

As you can see in each method, I call the Find method on the List items and instantiate the LookupItemIdMatch class passing in the search item.  I then call the property to return the correct predicate. I like this solution, its clean, elegant, and promotes code reuse. Oh, there is one other benefit to using predicates, they run faster than if you were to use foreach loops.  The performance increase isn't earth shattering, but faster nonetheless.

I hope in showing how I made use of predicates can help you.