I really never understood the difference of why one would use a static readonly property vs. a const, until now.  I very much dislike having string values hardcoded and would rather make them strongly typed to use throughout the application.  This works great, unless those constants can’t be determined until runtime.  So here is my solution, make them public static readonly members that read config file settings to help get the value at runtime.

Example:

 

    public static class MyPages

    {

        /// <summary>

        /// Login Page Url

        /// </summary>

        public static readonly string Login = GetUrl(“/Login/Login.aspx”);

 

 

        private static string GetUrl(string page)

        {

            return Settings.Default.WebRoot + page;

        }

 

Notice that I have a static class with a private method that goes out to the settings and updates the url with a value from the settings class.  This allows the URL to be configurable at runtime, for instance, the url code become relative, rootlevel, or other means.

 

Your thoughts?

 

Technorati Tags: ,

Continuing on from a previous post that looked at the Environment Settings of Visual Studio, here is my take on some Project and Solution areas that I have customized:

 

Tools – Options – Projects and Solutions – General

 

image

 

Notice, I have changed the locations where my projects go.  Also, I moved my templates location to a custom area that I back up nightly to a removable drive. I have also turned off the Track Active Item, and Show Output Window.  Just extra noise to me.

 

Tools – Options – Projects and Solutions – Build and Run

This area has only one feature that I changed and that is the build output verbosity. 

 

Notice in the picture there is also a VB Defaults area that sets information like Option Explicit, etc…

I remember when I used to teach for ExecuTrain that anytime I had to learn a new program, I would spend at least an hour going through the menu items one by one.  This really helped me to become really familiar with the product.  I stopped doing that for some idiotic reason a while back, maybe because I felt I didn’t have enough time.  I have made a goal to examine one program a week in depth, going through all the menu options and keyboard shortcuts.  I was inspired to do this because of Sara Ford’s daily tips for Visual Studio.  The first application I am tackling is Visual Studio 2008, starting with the options dialog and the environment settings. 

At each area, I have linked to the help online.  Here are some of my “Aha” moments.

Tools – Options – Environment – General

  • I turned off Animate environment tools.  This is not a must for me and may speed up my environment.
  • Restore File Associations button – This is good to know.  I installed SharpDevelop the other day and had all of my cs files registered with that application.  I manually reregistered with Visual Studio.

Tools – Options – Environment – AutoRecover

I have turned this off.  Especially since I am using source code control.  Everyone should be saving their work frequently.

Tools – Options – Environment – Find and Replace

I checked the Hide Find and Replace window after a match is located since I use the shortcut keys to Find Next (F3).

Tools – Options – Environment – Fonts and Colors

There are so many configurable settings in here:  The thing that I found interesting when looking for the help was finding out that the Printer can have different settings than the text editor.  Great when you have black backgrounds.

Tools – Options – Environment – Help – General

I changed the following properties on this:

  • Show Help using the Integrated Help viewer.  Comes up in the IDE.
  • Unchecked Highlight search terms, too much noise for me, especially when the keyword can be in the document many times.
  • Unchecked include partial matches for the local search results.

Tools – Options – Environment – Help – Online

I thought this was interesting.  I will check to see if I can add custom providers to the search criteria.  It would be great to add Dan Appleman’s SearchDotNet.

 

Tools – Options – Environment – Keyboard

Keyboard shortcuts are a topic in themselves.  I don’t know where I would be without them.  One of the things that you might try is just typing in some keyword text into the show commands containing window to get a feel for commands that might be candidates or already have shortcut keys.

Tools – Options – Environment – Startup

I personally show an empty environment, however, if the company I worked for had a developer RSS feed to for tips and tricks, I would show the start page and modify the news channel to that feed.

Tools – Options – Environment – Web Browser

These options seem a little flaky.  I can’t get another search engine other than Live to come up.  Oh well, I use slick run anyway to get to searches on the web.

 

As you can see there are a lot of features that I am discovering just by going through these items.  Hopefully you can benefit from them also.

 

 

Technorati Tags: ,

When I am searching on Google by default, unless I go to Advanced Search, all searches don’t care about old content.  A parameter can be added to the url to restrict contents by date.  I have created a magic word in SlickRun to accommodate this type of search.  Here is the parameter and some possible values:

Parameter:  as_qdr

  • d[number] – within the past number of days.  For example, d15 would be within the past 15 days.
  • w[number] – within the past number of weeks.
  • y[number] – within the past number of years.

Below is my magic word:

image

I have the same for weeks and years.

 

Technorati Tags: , ,

As I was doing some reading on the web, I came across this post from Scott Guthrie on Registering User controls in the web.config file.  I found this very tip very handy as we use lots of custom controls in our web site.  Use this in combination with a configsource attribute and it makes your code a lot cleaner.

 

Here is the post:

http://weblogs.asp.net/scottgu/archive/2006/11/26/tip-trick-how-to-register-user-controls-and-custom-controls-in-web-config.aspx

 

Technorati Tags: , ,

If you have never used any of the tools provided by Sysinternals (now owned by Microsoft), there is a place to download the whole shebang.

http://www.microsoft.com/technet/sysinternals/Utilities/SysinternalsSuite.mspx

 

I would say that these products are necessities for any developer.

This has finally gotten to me.  Every time that I connect my USB external drive, I the Autorun Dialog.

image

This is dialog that I want to be rid of.  Fortunately there are a lot of sites that give examples on how to do this.  The way I like is the following:

 

Create or modify a new DWORD named NoDriveTypeAutorun at the following key

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\policies\Explorer

 

Here is a table of options you can choose from to set the value of this DWORD:

 

 

Hex                   Meaning

0×1                    Disables Autoplay on drives of unknown type.

0×4                    Disables Autoplay on removable drives.

0×8                    Disables Autoplay on fixed drives.

0×10                  Disables Autoplay on network drives.

0×20                  Disables Autoplay on CD-ROM drives.

0×40                  Disables Autoplay on RAM drives.

0×80                  Disables Autoplay on drives of unknown type.

0xFF                  Disables Autoplay on all types of drives

 

Technorati Tags: , ,

I right clicked on the Error List in Visual Studio this morning.  Usually I just use the shortcut key (CTRL+W, E).  Lo and behold, the context menu had the ability to create TFS artifacts based upon the error.

image

 

It includes the error message in the item being created.  Pretty cool huh.  In the end I was kind of hoping that I could capture my todos in code, right click and create new tasks based upon the commented TODO.  Doesn’t look like that is the case.

 

Technorati Tags: , ,

I just ran across a post on Lifehacker about Personal Unit Tests.  As a fan of unit testing, I thought this was very appropriate. 

http://lifehacker.com/software/goals/check-your-productivity-with-personal-unit-tests-306440.php

 

Technorati Tags:

  One of my colleagues and I were wondering if there was an easy way to help make Visual Studio Shortcut Keys more discoverable.  To give it a try I made a DXCore plugin with a tool window to achieve this.  The key to this is setting up an event handler when a command in Visual Studio has finished firing.

 

image

 

1.  Create a new tool window plugin with the DXCore framework.  This is pretty simple.

2.  The key is to attach a handler to CommandEvents AfterExecute(…) event handler and  loop through each command in ApplicationObject.Commands.  If a Command has Bindings show them in a listbox or textbox in the tool window.  It really is pretty simple.  For a copy of code, please leave a comment.  I will try to post it in a Codeplex project for DXCore Plugins.

 

Technorati Tags: , , ,

« Previous PageNext Page »