Blog Home  Home Feed your aggregator (RSS 2.0)  
Code to Live, Live to Code
Randy Patterson's Blog
 
 Sunday, May 17, 2009

WindowsAzure

After conferring with several Microsoft Windows Azure Speakers and Azure Project Managers at TechEd last week, I was able to ferret out a tentative release schedule for Windows Azure.

  • Azure Platform and Services – Commercial Release on track for PDC this year (Nov 2009)
  • Visual Studio 2010 – On track to be released at PDC this year.  (Nov 2009)
  • Window Azure pricing and Service Level Agreements on track for a July 2009 announcement.
  • SQL Server Data Services Relational Data  – Beta this summer, release expected by the end of 2009.
  • Visual Studio 2010 Public Beta – Available in the next couple of weeks.

This is good news.  In just a couple of months we’ll have a good idea of what “Cloud Services” will cost and this will determine it’s viability for Small, Medium and Enterprise customers.  Without this information, it becomes impossible to plan ahead or convince potential customers to invest in Cloud Services development.   Also,  with a release date in sight and, hopefully, a stabilization of features, we can focus the the potential uses for this new technology instead of looking into the ever changing feature list.

Keep in mind that these dates are speculative and may change depending on bug feedback to Microsoft.  However,  each Speaker or Project Manager that would give me a timeline stated that Azure and VS 2010 was on track for release around PDC this year.

Sunday, May 17, 2009 7:15:21 PM (Eastern Daylight Time, UTC-04:00)  #       |  Trackback
 Monday, March 30, 2009

 

With over 500 attendees and 11 tracks to choose from, the Orlando Code Camp was once again a huge success!   Congratulations to all of the volunteers that helped organize this event.

I gave a presentation on an introduction to the Unity Application Block - Understanding Inversion of Control and Dependency Inversion Principles by introducing the Unity Application Block into an existing application.  You can download my presentation slides and code samples here

 

I enjoyed meeting everyone in Orlando,  hope to see you next year.

Randy Patterson

Monday, March 30, 2009 7:27:39 PM (Eastern Daylight Time, UTC-04:00)  #       |  Trackback
 Thursday, February 05, 2009

 

I have the privilege of giving two presentations at the South Florida Code Camp February 7th in Miramar Florida

 

Visual Studio Team System 2008 Development Edition

This session will cover the advanced tools available in Visual Studio 2008 Professional and Development Editions. We will quickly dive deep into using Code Metrics to facilitate Unit Testing and help improve code quality. Then we’ll dig into the details of Code Coverage, Static Analysis and Profiling to round off the tools at your disposal.

 

Introduction to the Unity Application Block

This session will focus on understanding Inversion of Control and Dependency Inversion Principles by introducing the Unity Application Block into an existing application. We will decompose an application into several loosely coupled components and demonstrate how Unity is used to locate and load your dependencies. Numerous code examples will cover Unity configuration, Unit Tests and object lifetime management. We will also demonstrate how the Unity Application Block helps facilitate the Open-Closed Principle and the Single Responsibility Principle (SRP) using Decorator Chains.

 

You can register for the event HERE.   Hope to see you there.

Thursday, February 05, 2009 7:28:38 PM (Eastern Standard Time, UTC-05:00)  #      Events  |  Trackback
 Monday, January 05, 2009

SFCodeCamp2009

 

The South Florida Code Camp 2009 has opened Speaker Registration for the February 7th Free Code Camp in Miramar Florida.  Code Camps are a great opportunity for local developers to give presentations to their peers. If you’ve ever wanted to give speaking a try, Code Camps provide an excellent environment to do so.

Monday, January 05, 2009 7:24:25 PM (Eastern Standard Time, UTC-05:00)  #       |  Trackback
 Saturday, October 04, 2008

I've been using ReSharper for nearly 2 1/2 years now and I can't imagine trying to program without it.  However, one of the greatest challenges to being productive with ReSharper is learning the daunting list of keys.  Many of the Resharper features are highly discoverable using visual indicators such as icons "squiggly" lines but most refactoring and navigation activities require memorizing numerous key presses....or does it?

Refactor This

There are dozens of key presses used for Navigating and Refactoring your code and many are only valid in certain contexts.  For Example, it doesn't make sense to attempt the Introduce Variable (Ctrl+Alt+V) refactor when your cursor is on a method signature.  Fortunately, ReSharper has an aggregate key press that will show you all of the refactorings appropriate for the current context. 

image

You no longer have to remember that Ctrl+F6 allows you to change a method signature you simply remember to press  Ctrl+Shift+R and select the Change Signature refactor.

image

As you can see "Refactor This" shows all the refactorings appropriate for the current context but it also includes the key presses for the ones that have mappings.  As you find yourself using certain items over and over you will slowly remember those keys and learn them at your own pace.  Furthermore, those refactorings that do not have a mapping are still available using this aggregate key. I often use "Pull Members Up" to "pull" a new method into the class's Interface saving me time from the tedious cut and paste. This is a huge win for discoverability as I would never have known this refactoring existed without "Refactor This".

Navigate From Here

ReSharper offers an aggregation key for Navigating your code that is just as powerful as Refactor This.

image

 

image

Using these two keys you gain access to most of what ReSharper has to offer and allows you to discover which Refactoring and Navigation features you like most, without the hassle of learning everything first. 

Now What

When beginning ReSharper there are a few steps I highly recommend.

  1. Download the ReSharper Key Map file
  2. Print the Key Map and hang it near your monitor where you can easily find it
  3. Highlight the "Navigation From Here" and "Refactor This" keys
  4. Highlight a few other important keys so you can quickly locate them when needed

 

Below is a link to the ReSharper map containing keys I find most useful highlighted for you.

 

Saturday, October 04, 2008 8:55:43 AM (Eastern Daylight Time, UTC-04:00)  #      ReSharper  |  Trackback
 Sunday, September 28, 2008

In my previous post I covered the configuration of the Unity Application Block for Constructor Injection without modifying the class being injected.  In this post I will cover Property Injection and how write API and XML configuration.

The following code has a dependency on the ILogger class exposed through a public property in line 10 (Property Injection).

public class MainFormPresenter
{
    private readonly IProductRepository _productRepository;

    public MainFormPresenter(IProductRepository productRepository)
    {
        _productRepository = productRepository;
    }

    public ILogger Logger { protected get; set; }

    public IList<Product> GetAllProducts()
    {
        Logger.Log("Start LINQ Query");

        return _productRepository
            .Query(p => p.Name.StartsWith("M"))
            .OrderBy(p => p.Name)
            .ThenByDescending(p => p.ListPrice)
            .ToList();
    }
}

Without the [Dependency] attribute, Unity has no idea that we need a class created and injected into the Logger Property.  Using the container API it's a trivial matter of informing Unity of our requirements. Lines 9 and 10 in the code below will tell Unity that whenever class MainFormPresenter is created, inject Property "Logger" with a class that matches it's type.   In addition, since the property type is ILogger, Unity needs a mapping to a concrete class or it will throw an exception (line 7).

IUnityContainer unityContainer = new UnityContainer();

//Configure Container
unityContainer
    .RegisterType<IProductRepository, ProductRepository>()
    .RegisterType<DataContext, AdventureWorksDataContext>()
    .RegisterType<ILogger, DebugLogger>();

unityContainer.Configure<InjectedMembers>()
    .ConfigureInjectionFor<MainFormPresenter>(new InjectionProperty("Logger"));

The following XML snippet will perform the same configuration

  1: <type type="UnityDemo.Views.MainFormPresenter, WindowsFormsApplication3">
  2: <typeConfig extensionType="Microsoft.Practices.Unity.Configuration.TypeInjectionElement, Microsoft.Practices.Unity.Configuration">
  3: 	<property name ="Logger" propertyType="UnityDemo.Logging.ILogger, WindowsFormsApplication3"/>
  4: </typeConfig>
  5: </type>

 

Related Posts:

POCO and Unity Application Block Part I - Constructor Injection

 

Sunday, September 28, 2008 10:00:01 AM (Eastern Daylight Time, UTC-04:00)  #      C# | Unity Application Block  |  Trackback
 Sunday, September 21, 2008

Using Plain Old CLR Objects (POCO) with the Unity Application Block

Plain old CLR objects is a term borrowed from Java (POJO) that refers to objects that are not entangled with framework specific code or dependencies.  For Example, when classes have multiple constructors you can add the [InjectionConstructor] Attribute to the constructor that you want Unity to use.

public class MainFormPresenter
{
    private readonly IProductRepository _productRepository;

    public MainFormPresenter()
    {
        //Do Something Profound
    }

    [InjectionConstructor]
    public MainFormPresenter(IProductRepository productRepository)
    {
        _productRepository = productRepository;
    }

    public IList<Product> GetAllProducts()
    {
        return _productRepository
            .Query(p => p.Name.StartsWith("M"))
            .OrderBy(p => p.Name)
            .ThenByDescending(p => p.ListPrice)
            .ToList();
    }
}

This, however, is where POCO advocates become vocal.  The problem is by adding the attribute our class has been "polluted" with Unity specific code and it would become difficult to replace Unity with another framework.  Fortunately, Unity also allows you to accomplish the same thing using API configuration or XML configuration files.

Selecting a Constructor using the Unity API

Using the Unity API to configure which constructor to use takes just one line of code:

IUnityContainer unityContainer = new UnityContainer();

//Configure Container
unityContainer.RegisterType<IProductRepository, ProductRepository>()

//Configure constructor for MainFormPresenter
unityContainer.Configure<InjectedMembers>()
    .ConfigureInjectionFor<MainFormPresenter>(new InjectionConstructor(typeof (IProductRepository)));

Lines 7 and 8 tell unity that when the class MainFormPresenter is instantiated use the constructor that has a single parameter of type  IProductRepository. This information is difficult to find in the documentation but is straight forward and easy to read.

Selecting a Constructor using XML

Configuring Unity using an XML file is a bit more verbose but fairly easy to understand nonetheless. The first step is to tell Unity to load your config file using code similar to this.

IUnityContainer unityContainer = new UnityContainer();

//Configure Container
UnityConfigurationSection section = (UnityConfigurationSection)ConfigurationManager.GetSection("unity");
section.Containers.Default.Configure(unityContainer);

Next, update your App.config, Web.config or whatever config file you choose to use to include information to inform Unity which constructor to use.

  1: <types>
  2:   <type type="UnityDemo.Views.MainFormPresenter, WindowsFormsApplication3">
  3:     <typeConfig extensionType="Microsoft.Practices.Unity.Configuration.TypeInjectionElement, Microsoft.Practices.Unity.Configuration">
  4:       <constructor>
  5:         <param name ="productRepository" parameterType="AWRepository.Products.IProductRepository, AWRepository">
  6:           <dependency />
  7:         </param>
  8:       </constructor>
  9:     </typeConfig>
 10:   </type>
 11:   <type type="AWRepository.Products.IProductRepository, AWRepository" 
 12:         mapTo="AWRepository.Products.ProductRepository, AWRepository"/>
 13: </types>

Lines 4-8 inform unity which constructor to use in much the same way as the API configuration preceding it.  The <dependency /> element tells unity to resolve the parameter type (IProductRepository in this case) using the mapping it already contains. 

Conclusion

Allowing configuration information, such as constructor selection, without modifying the injected class not only allows POCO but also allows us to use non-friendly dependency injection classes that we cannot modify.   For example,  Generated classes for LINQ to SQL DataContext contains 4 constructors, two with one parameter and two with two parameters. Due to the similar constructor signatures Unity will not be able to determine which one to use and will throw an exception if no guidance is provided. Fortunately we can use API or XML configuration to inform Unity how to handle these unfriendly classes.  I tend to favor the use of Attributes because they are easier to use and easier to understand intent. However, It is critical to provide indirect configuration to allow the use of classes that are not friendly to dependency Injection and to allow POCO classes when there is a need.

In my next post I will discuss how to Configure Unity for Property Injection without using the [Dependency] Attribute

 

Related Posts:

POCO and Unity Application Block Part II - Property Injection 

 

kick it on DotNetKicks.com
Sunday, September 21, 2008 8:13:48 PM (Eastern Daylight Time, UTC-04:00)  #      C# | Unity Application Block  |  Trackback
 Monday, September 15, 2008

I will be speaking about the Unity Application Block, Dependency Injection and Inversion of Control at the Sarasota .Net Users Group.

Wed, September. 17, 2008 at 6:00pm - 8:00pm.   Location: Sarasota Community Foundation, 2635 Fruitville Rd., Sarasota, FL 34237 (just west of Tuttle on the north side of Fruitville).

The Microsoft Unity Application Block is a lightweight Dependency Injection Container that is currently being incorporated into the latest releases of Enterprise Library and the Composite Application Library (Prism). This presentation will give an introduction to Dependency Injection and Inversion of Control concepts and an overview of how to use and configure the Unity Application Block to build loosely coupled applications.

Agenda:

  • Overview of Inversion on Control (IoC) Containers
    • Understanding Inversion of Control
    • Understanding Dependency Injection
  • Unity Application Block
    • Constructor Injection
    • Property (setter) Injection
  • Unity Configuration
    • Understanding Object Lifetime Management
    • Using API Configuration
      • RegisterType
      • RegisterInstance
    • Using Configuration Files
  • Managing Dependencies
  • Understanding Loosely Coupled Components
  • When is Dependency Injection Appropriate

Presentation slides and code sample

Monday, September 15, 2008 8:16:51 PM (Eastern Daylight Time, UTC-04:00)  #      Events | Unity Application Block  |  Trackback
 Saturday, July 12, 2008

I just love ReSharper (R#) by JetBrains, it has substantially increased my productivity while writing, and navigating code.

Quickly highlight all usages of a symbol within the current file.   To use,  place your cursor on the Type or Variable that you want to highlight then press Shift+Ctrl+F7

Highlight Usages

The Write operations are highlighted in light Red and the Read operations are highlighted in light Blue.  Pressing ESC removes the highlights. Furthermore, the R# Marker Bar to the right of your code uses to same colors to highlight all usages in the current file.  Just click on the horizontal mark to quickly navigate to the usage.

image

Saturday, July 12, 2008 8:28:06 PM (Eastern Daylight Time, UTC-04:00)  #      C# | ReSharper  |  Trackback
 Friday, June 27, 2008

It's been six months since my previous article "10 Podcasts Every Developer Should Listen To" so I thought I would do a follow up article outlining some of the new quality podcasts available to developers.

Alt.Net Podcast Good quality weekly podcast covering topics like adopting Agile, Dependency Injection and Continuous Integration
The Java Pose Helps to keep me informed of the innovations happening in the Java world and you get a catchy intro tune for free. 
The Thirsty Developer A weekly podcast covering a wide variety of .NET topics like SCRUM, Continuous Integration, Cyclomatic Complexity and Silverlight 2. 
Parlays Good architecture podcast with a wide variety of topics that focus on Java, Google and Apple. 
Radio TFS Excellent podcast on all things Team Foundation Server.  Highly recommended if you use or plan to use TFS
ThoughtWorks - IT Matters Discusses the business and technology issues facing the IT Industry with occasional appearances from people like Martin Fowler.
Deep Fired Bytes Despite the unhealthy name of this podcast it covers a healthy variety of IT Topics.

 

If I've missed any developer related podcasts that you find helpful please let me know.

kick it on DotNetKicks.com

Friday, June 27, 2008 5:21:25 PM (Eastern Daylight Time, UTC-04:00)  #      Podcast  |  Trackback
Copyright © 2009 Randy Patterson. All rights reserved.
DasBlog 'Portal' theme by Johnny Hughes.