Chris Eargle

Life Student of the Kodefu Arts

Announcing Windows Azure

by chris 27. October 2008 11:50

I just learned that Windows Azure has been announced, presumably at PDC 2008. It's brand new, so visit the site to learn more and download the ctp.

Windows Azure is a cloud services operating system that serves as the development, service hosting, and service management environment for the Azure Services Platform. Windows Azure provides developers with on-demand compute and storage to host and manage web applications on the internet through Microsoft data centers.

Between this and Live Mesh, I feel as though we're in the middle of a huge paradigm shift.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

azure, live mesh

Bleeding Edge

E-mail | Kick it! | DZone it! | del.icio.us
Permalink | Comments (0) | Post RSSRSS comment feed

ContinueOnError for Project Builds

by chris 9. October 2008 09:29

I've seen a few questions in the forums where the poster wants the build to fail for certain projects but not others. This can be accomplished through metadata and item batching.

Here is the item group that defines the projects.

<ItemGroup>
    <
Projects Include="$(MSBuildProjectDirectory)\DataAccess\DataAccess.csproj">
        <
Group>Build</Group>
        <
Title>Data Access</Title>
        <
Description>Data Access Layer</Description>
        <
ContinueOnError>False</ContinueOnError>
    </
Projects>
    <
Projects Include="$(MSBuildProjectDirectory)\Business\Business.csproj">
        <
Group>Build</Group>
        <
Title>Business</Title>
        <
Description>Business Layer</Description>
        <
ContinueOnError>False</ContinueOnError>
    </
Projects>
    <
Projects Include="$(MSBuildProjectDirectory)\NonCritical\NonCritical.csproj">
        <
Group>Build</Group>
        <
Title>NonCritical</Title>
        <
Description>A Non Critical Project</Description>
        <
ContinueOnError>True</ContinueOnError>
    </
Projects>
    <
Projects Include="$(MSBuildProjectDirectory)\Presentation\Presentation.csproj">
        <
Group>Build</Group>
        <
Title>Presentation</Title>
        <
Description>Presentation Layer</Description>
        <
ContinueOnError>False</ContinueOnError>
    </
Projects>
</
ItemGroup>

Here is the call to the MSBuild task.

<MSBuild Projects="@(Projects)" ContinueOnError="%(ContinueOnError)" />

Since ContinueOnError is defined as metadata for the Projects items, you can access it in a batching scenario by using the % symbol. When assigned to the ContinueOnError attribute, it evaluates the text contained within the metadata, in this case True or False.  One side effect of this is that all of the ContinueOnError=False projects will be executed before the True projects. 

I don't like this approach, because I consider a compilation failure a failed build. However, this should help you out if you're faced with a scenario where this functionality is required.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

msbuild

Kodefu

E-mail | Kick it! | DZone it! | del.icio.us
Permalink | Comments (0) | Post RSSRSS comment feed

MSBuild Extension Pack First Impression

by chris 8. October 2008 08:28

Mike Fourie has begun a project to combine two of the larger MSBuild task libraries. FreeToDev and SDC tasks have a lot of overlap, so I believe the MSBuild Extension Pack is a great endeavor to simplify the life of many of us build architects. However, I do have a gripe after reading the description on the project page.

It implements a TaskAction based design which improves usability and maintenance whilst reducing the code base, e.g. to start or stop a website, typically two task files would be created to perform each task, whereas the pack accomplishes this in a single task files using TaskAction=”Stop” and TaskAction=”Start”.

I feel that a "TaskAction based design" decreases cohesion. Each task should be like a method: the name describes what it does and the attributes are the parameters to do it. If you start coding tasks that change behavior, then you've effectively given the class (remember, tasks are classes) too much responsibility. If multiple tasks have similar responsibilities, the correct approach is to abstract. Create a base class with the common elements, encapsulate what varies, then implement that variation in the child classes which are represented in MSBuild as tasks.

In the example given on the project page, I would prefer to have <Website.Start ... /> and <Website.Stop ... /> than <Website TaskAction="Start" ... /> and <Website TaskAction="Stop" ... />

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

msbuild

Kodefu

E-mail | Kick it! | DZone it! | del.icio.us
Permalink | Comments (0) | Post RSSRSS comment feed

Tonight's Meeting

by chris 8. October 2008 07:50

Lou Vega will be presenting at the Columbia Enterprise Developers Guild tonight. The topic is "A Closer Look at Windows Mobile – Using SMS and State & Notifications Broker." Systemtec is sponsoring the event and will be providing food from Moe's.

Visit the website for more information.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

mobile

CEDG

E-mail | Kick it! | DZone it! | del.icio.us
Permalink | Comments (0) | Post RSSRSS comment feed

Prop Snippet Fail

by chris 7. October 2008 09:22

This is one that belongs on failblog. I happen to be using Visual Studio 2005 at work, so the prop snippet generates a private member variable to encapsulate in a property. In this case, I needed the property "Value". Guess what happens?

        private string value;

        
public string Value
        {
            
get { return value; }
            
set { value = value; }
        }

Fail. The only thing that needs to be done to correct this is to qualify value in the setter. 

            set { this.value = value; }

There's no reason to make a better prop snippet now that it generates automatic properties in Visual Studio 2008. This problem merely amused me.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

fail, snippet, c#

Kodefu

E-mail | Kick it! | DZone it! | del.icio.us
Permalink | Comments (0) | Post RSSRSS comment feed

Parsing Properties and Items

by chris 6. October 2008 12:32

MSBuild files are loaded and parsed in order. This means that properties and items are in scope if they have been previously defined anywhere within the load chain. Here's an example.

Test.proj

<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
    
    <
PropertyGroup>
        <
HelloWorld>Hello World!</HelloWorld>
    </
PropertyGroup>

    <
ItemGroup>
        <
Files Include="*.*"/>
    </
ItemGroup>

    <
Import Project="Test.properties" />
    
    <
Target Name="Build">
        <
Message Text="$(GotHere)" />        
        <
Message Text="$(FileList)" />        
    </
Target>
    
</
Project>

Test.properties

<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
    
    <
PropertyGroup>
        <
GotHere>Got here, $(HelloWorld)</GotHere>
        <
FileList>@(Files)</FileList>
    </
PropertyGroup>
        
</
Project>

When you run MSBuild test.proj, you will receive the following output.

    Got here, Hello World!
    Test.proj;Test.properties

If you were to move the Import task above the property and item definitions, your results will be different as the HelloWorld property and the Files item collection have not been defined.

This concept is important if you are attempting to break a large build file into smaller files. There may be dependencies between common properties & items and conditional properties & items. Conditional properties and items can be refactored out of the primary script (encapsulate what varies) and still use the common properties and items as long as they are defined before the conditional file is imported.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

msbuild, refactoring

Kodefu

E-mail | Kick it! | DZone it! | del.icio.us
Permalink | Comments (0) | Post RSSRSS comment feed

Lazy Loading Properties

by chris 1. October 2008 12:28

What do you do when you are loading hundreds of objects and it's taking too long? When you instantiate the object in a vacuum, it runs very fast. However, you run a few tests and determine a collection on the object causes a bottleneck if a call to load the collection occurs many times in succession.

    public class Customer
    {
        
private List<Account> accounts = SlowLoadMethod();

        
public IList<Account> Accounts
        {
            
get{ return accounts; }
        }

        ...
    }

If the property doesn't need to be accessed immediately upon instantiation, we can use a technique called lazy loading. This means the data isn't loaded into the member variable and the call to the slow method will not occur until the first time the property is accessed. This is easy to accomplish via a conditional check inside the property's get accessor.

    public class Customer
    {
        
private List<Account> accounts;

        
public IList<Account> Accounts
        {
            
get
            {
                
if (accounts == null)
                {
                    accounts = SlowLoadMethod();
                }

                
return accounts;
            }
        }

        ...
    }

In this example, the accounts private member is null until the first time that someone accesses the Accounts property. At that point, the accounts private member is assigned a value from the SlowLoadMethod. Subsequent accesses to the Accounts property skip this step and returns the field as usual.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

c#, properties

Kodefu

E-mail | Kick it! | DZone it! | del.icio.us
Permalink | Comments (0) | Post RSSRSS comment feed

Powered by BlogEngine.NET 1.3.1.0
Theme by Mads Kristensen

About the author

Chris Eargle Chris Eargle
Enterprise .NET developer in Columbia, SC.

E-mail me Send mail

Pages

  • Presentations

Twitter Updates

    Recent comments

    • Dev InTENsity (3)
      Chris Eargle wrote: Thanks for attending my presentations, Seth! In… [More]
    • Set Operations in MSBuild (1)
      FreeToDev wrote: Very nice post. Makes me wonder why I wrote tasks … [More]
    • Dev InTENsity (3)
      Seth Richards wrote: I saw both your C# 3.0 (I came up with the 'why ex… [More]
    • Dev InTENsity (3)
      Scott Ames wrote: I went to your presentation in Walthan for Code Ca… [More]
    • Generics Don't Make Me Sad (1)
      Matt Sheppard wrote: Cheers, I can't remember if I was aware of either… [More]
    • C# 3.0 Presentation (1)
      vijay wrote: Good post Thanks, Vijay [More]
    • Format Solution (4)
      Joe wrote: I added a couple of lines to FormatProjectItem() t… [More]
    • Sessions Galore (1)
      Lou wrote: I'll have to get you down here soon - I'll e-mail … [More]
    • Redeemed (3)
      Fred Beiderbecke wrote: It wasn't you, it was some of the others in the ro… [More]
    • South Florida Code Camp (1)
      Jason Meridth wrote: You've mentioned the only latest difference betwee… [More]

    Archive

    • 2008
      • January (4)

    Tags

    • activex
    • addin
    • ado.net data services
    • ajax
    • architecture
    • astoria
    • azure
    • beta
    • bug
    • c#
    • code camp
    • com
    • consolas
    • continuous integration
    • conversion
    • ctp
    • database
    • deployment
    • design
    • design principles
    • download
    • ebook
    • entity
    • entlib
    • environment variables
    • expression blend
    • fail
    • font
    • framework
    • gadget
    • generics
    • grid
    • guidelines
    • icon
    • interfaces
    • jacksonville
    • lamdba
    • linq
    • linqtosql
    • list
    • live mesh
    • macro
    • mobile
    • msbuild
    • msdn
    • msi
    • mvc
    • powertoy
    • preview
    • properties
    • ray ozzie
    • refactoring
    • regasm
    • russ fustino
    • security
    • serialization
    • silverlight
    • snippet
    • source code
    • sql server
    • sqlmetal
    • starter kit
    • stream
    • string
    • trial
    • usability
    • ux
    • vbscript
    • vista
    • visual studio
    • vs2008
    • wcf
    • web
    • winforms
    • wpf
    • xml

    Categories

    • RSS feed for Bleeding EdgeBleeding Edge (5)
    • RSS feed for CEDGCEDG (2)
    • RSS feed for GeneralGeneral (1)
    • RSS feed for KodefuKodefu (19)
    • RSS feed for Path NotesPath Notes (7)
    • RSS feed for PresentationPresentation (5)
    • RSS feed for TechniquesTechniques (2)
    • RSS feed for TrainingTraining (5)
    • RSS feed for WeaponsWeapons (4)
    • RSS feed for ZenZen (5)

    Archive

    Blogroll

    • RSS feed for Structure Too BigStructure Too Big
      • Should you buy an exten...
      • WorldMaps Update
      • MSDN Roadshow -- coming...
    • RSS feed for Chris CraftChris Craft
      • Pimp My Phone – D...
      • Pimp My Phone – D...
      • Pimp My Phone – D...
    Download OPML file OPML

    Disclaimer

    The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

    © Copyright 2008

    Sign in