in

vbCity Blogs

New (temp) place for vbCity Blogs

Mike McIntyre's .NET Journal

November 2008 - Posts

  • ANTS Profiler 4.0 Product Review

    ANTS Profiler version 4.0, released September 2008, adds many new features to this already powerful .NET profiling product.

    Web:

    www.red-gate.com
    Phone:

    +1 866.733.4283
    Price:

    $395/$495 Pro

    Quick Facts: ANTS Profiler is a tool for profiling applications written in any of the languages supported by the .NET framework. ANTS Profiler profiles all .NET applications, including ASP.NET web applications, Windows Services and COM+ applications.

    This is the third time I've reviewed ANTS Profiler from Red Gate Software.

    I've been a loyal user since version 1.0. This was an excellent product when that version was released and has only gotten better with each release.

    This is an ingeniously simple to use, powerful tool for optimizing your .NET applications. You'll be profiling your applications in less than 30 minutes of installing this software.

    Quick Start

    ANTS menu is installed in the Visual Studio IDE.

     Launch ANTS Profiler from within Visual Studio

    Tests are configured with the ANTS Performance Profiler Settings dialog.

    Set your profiling session

    You can include performance counters.

    Picking the performance counters

    Once settings are done just click the Start Profiling button. Your application will initialize, and you can start interacting with it and performing the tasks you want.

    While the profiling session is running you can view the profiler results window: 

    You can drill down into performance details.  One way to do this is to drag across a portion of the timeline at the top of the profiling session window:

     

    After your select a portion of the timeline, calls and timings will appear in the middle of the profile session window:

    Click a call line to view code with timings in the bottom of the profile session window:

    That's it.

    ANTS makes it very easy to see exactly which code is underperforming.

    Profiles and individual test runs can be saved for later re-execution or analysis.

    Help, Tutorials, and Videos

    As easy as it is to use, Red Gate provides excellent help, tutorials, and videos for learning how to use ANTS Profiler.

    Check them out here: ANTS Profiler

    Summary

    To learn what ANTS Profiler 4.0 can do for you try a free trial version of the software. Download it here - ANTS Profiler 4.0 Trial Download

  • Visual Basic 2008 Pop Quiz - How can I add a Function to the String type? Part 2

     Extension methods are new in Visual Basic 2008.  This short blog series explores how extension methods can be used to add Subs and Functions to the .NET String type.

    Click here for an index of this blog series.

    Here's this post's sample code:

    Module StringExtensions

        ' Declare a String extension method named Browse

        '  that uses the string assigned to a variable of type String as a url

        '  to open a browser and navigate to the url.

        <Extension()> _

        Public Sub Browse(ByVal url As String)

            System.Diagnostics.Process.Start(url)

        End Sub

     

        ' Declare a String extension method name SplitCommaDelimited

        '  that splits a comma delimited string assigned to a variable of type String,

        '  splits it into a String array, then calls the String array's ToList method to

        '  return a List(Of String)

        <Extension()> _

        Public Function SplitCommaDelimited(ByVal commaDelimitedString As String) As List(Of String)

            Dim strings = commaDelimitedString.Split(",")

            Return strings.ToList

        End Function

     

    End Module

    A new extension method, SplitCommaDelimited, has been added to the StringExtensions module created in a previous post.  The comments in the code explain what this new extension method does.

    All that is required to be able to run these or similar extension methods is that they be in scope. If the StringExtension module is in scope, it is visible in IntelliSense and can be called as if it were an ordinary instance method.

    Where can you declare extension methods?

    Extension methods can be declared only within modules.

    Extension Method Precedence

    When two extension methods that have identical signatures are in scope and accessible, the one with higher precedence will be invoked. An extension method's precedence is based on the mechanism used to bring the method into scope. The following list shows the precedence hierarchy, from highest to lowest.

    1. Extension methods defined inside the current module.

    2. Extension methods defined inside data types in the current namespace or any one of its parents, with child namespaces having higher precedence than parent namespaces.

    3. Extension methods defined inside any type imports in the current file.

    4. Extension methods defined inside any namespace imports in the current file.

    5. Extension methods defined inside any project-level type imports.

    6. Extension methods defined inside any project-level namespace imports.

    Mike McIntyre

    http://www.getdotnetcode.com

  • Visual Basic 2008 Pop Quiz - How can I add a Function to the String type?

    Extension methods are new in Visual Basic 2008.  This short blog series will explore how extension methods can be used to add Subs and Functions to the .NET String type.

    Click here for an index of this blog series.

    Try this:

    1. Create a Visual Basic 2008 Windows Forms project.

    2. Add a module named StringExtensions to a Visual Basic 2008 Windows Forms project:

     

     

    2. To Form1 in the project add a form load handler based on this sample code:

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) _ Handles MyBase.Load

            ' Declare a variable of type String named url;

            ' assign a string containing a url to the variable.

            Dim url As String = "http://www.msdn.com"

            ' We can call the Browse estension method on the string assigned to the variable.

            url.Browse()

    End Sub

    3. Run the application.  Your browser should open and navigate to the MSDN home page.

    Nifty huh?  But just because you can, should you?  The next blog post in this series will provide another String extension method and discuss some guidelines for where and when you should use extension methods.

    Mike McIntyre

    http://www.getdotnetcode.com

     

    Imports System.Runtime.CompilerServices

     

    Module StringExtensions

        <Extension()> _

        Public Sub Browse(ByVal url As String)

            System.Diagnostics.Process.Start(url)

        End Sub

    End Module

     

  • Visual Basic 2008 Books (updated)

     When I first published this list on my .Net Resources blog October 2007, it contained eleven books.

    The list has grown so large that I am now hosting it on my Get Dot Net Code web site:

    Visual Studio 2008 Books

  • Silverlight Toolkit

    "The Silverlight Toolkit is a collection of Silverlight controls, components and utilities made available outside the normal Silverlight release cycle. It adds new functionality quickly for designers and developers, and provides the community an efficient way to help shape product development by contributing ideas and bug reports. This first release includes full source code, unit tests, samples and documentation for 12 new controls covering charting, styling, layout, and user input."

  • Agile Software Construction vs. Agile Software Remodeling - Round 1

    I've been thinking a lot lately about the difference between software construction and software remodeling, and how agile software development must vary for construction vs. remodeling. 

    Software construction is building version 1 of a software or system. Software remodeling is maintaining, refactoring, or adding features to an already constructed software application or system. (For brevity I will refer to a sofware application or system as just 'software' from this point on in this series)

    Construction and remodeling are similar in some ways but quite different in others.

    Consider the legacy aspect of software engineering:

    1. The legacy aspect in engineering new software is to make the software easy to remodel in the future; today's shiny new software should not become tomorrow's tarnished legacy software.
    2. The legacy aspect in remodeling new software is dealing with what already exists - the legacy software; how will a new feature play with the existing features, how should a refactoring be tested, how should a maintenance patch be applied to versions 1, 2, and 3 of an existing software, how can the software achitecture be kept current with good enginnering practices without breaking what already exists?

    In this blog series I will explore how agile software development applies in software construction and software remodeling. Agile software construction and agile remodeling are similar in some ways but quite different in others. This series will explain how agile planning, design, development techiques, testing and more should vary depening on whether you are constructing or remodeling a software.

  • Anonymous Types in Visual Basic 2008

    Visual Basic 2008 introduces anonymous types which enable you to create an object without declaring its data type. 

    Notice in the anonoymous type declaration below that there is no 'As' in the declaration to specify a type for the object it will create.

    user = New With {.FirstName = "Mike", .LastName = "McIntyre", .City = "Cobb"}

    When the declaration is compiled, the compiler will generate a class, instantiate an object containing the properties specified, and assign the object to the variable user.

    The anonymous type has no usable name, inherits directly from Object, and contains the properties you specify in declaring the object. It is because the name of the data type is not specified that the type is referred to as an anonymous type.

    The following example declares and creates variable user and assigns to it an instance of an anonymous type that has three properties, LastName, FirstName and City.

    Dim user = New With {.FirstName = "Mike", .LastName = "McIntyre", .City = "Cobb"}

    This code shows how the anonymous type's properties can be accessed in the same way a non-anonymous types properties are accessed:

    MessageBox.Show(user.FirstName & " " & user.LastName & " " & user.City)

  • What coming in Visual Basic 2010? - Collection Initializers

    Collection initializers will let you initialize collections with fewer lines of code.

    In the two examples below notice the use of 'From' to initial collections from lists.

    Dim colorList As New List(Of String) From {"Red", "Blue", "Green","Black"} 

    Dim statusDictionary As New Dictionary(Of String, Integer) From {{"Aproved", 1}, {"Disapped", 2},{"Needs More Info", 3}}}

  • Welcome to the new home of Mike McIntyre's .Net Journal

    Access previous posts at:  http://blogs.vbcity.com/mcintyre/

Copyright 1998-2009 vbCity.com LLC
Powered by Community Server (Non-Commercial Edition), by Telligent Systems