<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/atom.xsl" media="screen"?><feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-US"><title type="html">Steve's blog</title><subtitle type="html" /><id>http://blogs.msdn.com/steve/atom.xml</id><link rel="alternate" type="text/html" href="http://blogs.msdn.com/steve/default.aspx" /><link rel="self" type="application/atom+xml" href="http://blogs.msdn.com/steve/atom.xml" /><generator uri="http://communityserver.org" version="2.1.61025.2">Community Server</generator><updated>2007-04-03T09:11:00Z</updated><entry><title>StyleCop released</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/steve/archive/2008/05/27/stylecop-released.aspx" /><id>http://blogs.msdn.com/steve/archive/2008/05/27/stylecop-released.aspx</id><published>2008-05-27T11:41:00Z</published><updated>2008-05-27T11:41:00Z</updated><content type="html">&lt;P&gt;The static analysis tool FXCop, and its later relation Visual Studio Code Analysis, have been well known as static analysis tools which help improve the quality and resilience of your code.&amp;nbsp; I'm a big fan of this tool's ability to catch bugs and potential performance or security issues sooner in the development process.&lt;/P&gt;
&lt;P&gt;A lesser known tool named StyleCop, which was only available internally at Microsoft up until now, analyses the source code and checks that it conforms to suggested styling guidelines.&amp;nbsp; People often have their own preferred way of styling code, which is fine for a single-man project but can make it harder to work collaboratively.&lt;/P&gt;
&lt;P&gt;The first time I was encouraged to use StyleCop I initally found it irritating, but you soon learn to appreciate the benefit of consistent styling across a large body of code.&amp;nbsp; Certainly the goal here isn't to preach a religious viewpoint on the One True Way of utilising curly braces, but rather ensuring that you can quickly and easily read any part of the codebase; it's surprising how much difference consistency can make to this.&amp;nbsp; It also provides further checks on code documentation such as suitable headers, which isn't covered by the other tools.&lt;/P&gt;
&lt;P&gt;Read more about it on the &lt;A class="" href="http://blogs.msdn.com/sourceanalysis/archive/2008/05/23/announcing-the-release-of-microsoft-source-analysis.aspx" mce_href="http://blogs.msdn.com/sourceanalysis/archive/2008/05/23/announcing-the-release-of-microsoft-source-analysis.aspx"&gt;Source Analysis blog&lt;/A&gt;.&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8554323" width="1" height="1"&gt;</content><author><name>sthorne</name><uri>http://blogs.msdn.com/members/sthorne.aspx</uri></author></entry><entry><title>*sigh*</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/steve/archive/2008/05/16/sigh.aspx" /><id>http://blogs.msdn.com/steve/archive/2008/05/16/sigh.aspx</id><published>2008-05-16T18:36:00Z</published><updated>2008-05-16T18:36:00Z</updated><content type="html">&lt;P&gt;Okay, I'll admit it...my definition of shortly sucks.&amp;nbsp;Ten months between blog posts was very much not what I intended. All I can say is I got pulled into a couple of CAB projects for another bank which have sucked up all my time, but things have calmed down a bit and I hope to post a little more regularly now (yeah yeah, I know).&lt;/P&gt;
&lt;P&gt;So what momentous event caused me to start blogging again?&amp;nbsp; The &lt;A class="" href="http://blogs.msdn.com/tims/archive/2008/05/12/introducing-the-third-major-release-of-windows-presentation-foundation.aspx" mce_href="http://blogs.msdn.com/tims/archive/2008/05/12/introducing-the-third-major-release-of-windows-presentation-foundation.aspx"&gt;announcement by Tim Sneath&lt;/A&gt; that&amp;nbsp;.NET 3.5&amp;nbsp;Service Pack 1 is on the horizon, including the third major release of WPF.&amp;nbsp; What's more the long missed DataGrid control is making a WPF comeback in an out-of-band release.&amp;nbsp; This should make WPF a much more attractive proposition to those creating business applications; should certainly make the reams of data-binding code I've written to cope with WinForms limitations redundant.&lt;/P&gt;
&lt;P&gt;An interesting point a customer made to me the other day was that there's no clear guidance on where we've been, are or where we're going with smart client technologies.&amp;nbsp;A lot of phrases, acronyms and codenames get bandied about without a coherent view of how they all fit together, which can be confusing for someone who's coming to it all new, especially when explaining the benefits this technology can bring to non-technical people. I'm going to have a shot at bringing it together in some sort of simple top-level diagram, so watch this space.&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8513548" width="1" height="1"&gt;</content><author><name>sthorne</name><uri>http://blogs.msdn.com/members/sthorne.aspx</uri></author></entry><entry><title>Still here, just</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/steve/archive/2007/07/16/still-here-just.aspx" /><id>http://blogs.msdn.com/steve/archive/2007/07/16/still-here-just.aspx</id><published>2007-07-16T13:50:00Z</published><updated>2007-07-16T13:50:00Z</updated><content type="html">&lt;P&gt;So I've been on a CAB project based in Johannesburg for the last few months, which is my excuse for the woeful inattention I've paid to this blog in that time.&amp;nbsp; I hope to publish some of my learnings from the experience here shortly, but in the meantime I've been brushing up on some other interesting technologies around right now.&amp;nbsp; I've found &lt;A href="http://www.riemers.net/eng/Tutorials/XNA/Csharp/series1.php" mce_href="http://www.riemers.net/eng/Tutorials/XNA/Csharp/series1.php"&gt;Riemers XNA tutorials&lt;/A&gt; to be an excellent resource -&amp;nbsp;in case you've been living under a rock for the past year, &lt;A href="http://msdn2.microsoft.com/en-us/xna/default.aspx" mce_href="http://msdn2.microsoft.com/en-us/xna/default.aspx"&gt;XNA&lt;/A&gt;&amp;nbsp;is Microsoft's new game development platform targeting the Xbox 360 as well as the PC.&lt;/P&gt;
&lt;P&gt;The tutorials cover basics from creating your first triangle, to 3D terrain, lighting, bump mapping and many more cool things - one series of tutorials has you generating an entire combat flight sim.&amp;nbsp; Don't forget XNA is free to develop games for the PC and allows you to program games with minimum fuss using either C# or Visual Basic .NET.&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=3893797" width="1" height="1"&gt;</content><author><name>sthorne</name><uri>http://blogs.msdn.com/members/sthorne.aspx</uri></author></entry><entry><title>Activating WorkItems in a TabWorkspace</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/steve/archive/2007/04/18/activating-workitems-in-a-tabworkspace.aspx" /><id>http://blogs.msdn.com/steve/archive/2007/04/18/activating-workitems-in-a-tabworkspace.aspx</id><published>2007-04-18T13:06:00Z</published><updated>2007-04-18T13:06:00Z</updated><content type="html">&lt;P&gt;Apologies for those to whom the Smart Client Software Factory means nothing, but I thought I'd share a recent experience with regard to the TabWorkspace workspace control.&amp;nbsp; I do plan to come back and explain SCSF at a more fundamental level in later posts, but hopefully this will prove useful to anyone who has had similar issues.&lt;/P&gt;
&lt;P&gt;My problem related to automatically activating SmartParts and their associated WorkItems&amp;nbsp;hosted in a TabWorkspace.&amp;nbsp; Controls tagged with the [SmartPart] attribute automatically activate their associated WorkItem when activated, but unfortunately switching to a tab hosting the control is not enough to fire this event.&amp;nbsp; In my particular situation I had a status bar which I wanted updated with information from the active WorkItem, so I needed a way to capure that TabWorkspace control's SelectedIndexChanged event and activate the correct WorkItem.&lt;/P&gt;
&lt;P&gt;Whilst the TabWorkspace control does have an ActiveSmartPart property, SmartParts don't contain any special properties for getting at their associated WorkItem.&amp;nbsp; Given I knew the exact type of SmartPart I was going to be opening in the tab pages I could have simple casted to the appropriate type and got at the WorkItem that way, but this would have introduced tighter coupling and lack of reusability.&amp;nbsp; Instead I decided to keep a register of tab pages and associated WorkItems, so I created a Dictionary&amp;lt;TabPage, WorkItem&amp;gt; collection in my ShellLayoutView class.&amp;nbsp; I then used the Event Publication/Subscription model to fire an event when a WorkItem was created, and then used that event to&amp;nbsp;register the WorkItem against&amp;nbsp;the TabPage it appeared in.&lt;/P&gt;&lt;PRE&gt;[EventSubscription(EventTopicNames.RegisterWorkItem)]
public void RegisterWorkItem(object sender, EventArgs&lt;WORKITEM&gt; workItem)
{
    _registeredWorkItems[_rightWorkspace.SelectedTab] = workItem.Data;
}
&lt;/PRE&gt;
&lt;P&gt;Finally within the WorkItemController itself I added handlers for the WorkItem.Activated and WorkItem.Terminating events, to update the status bar of the shell application when the active WorkItem changed.&amp;nbsp; I'm still figuring all the intricasies of CAB/SCSF out and this may not have been the optimal solution, but it worked for me.&amp;nbsp; I'd love to hear from anyone who found better or alternative ways of achieving the same.&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=2172567" width="1" height="1"&gt;</content><author><name>sthorne</name><uri>http://blogs.msdn.com/members/sthorne.aspx</uri></author></entry><entry><title>Using Object Builder as a singleton factory</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/steve/archive/2007/04/11/using-object-builder-as-a-singleton-factory.aspx" /><id>http://blogs.msdn.com/steve/archive/2007/04/11/using-object-builder-as-a-singleton-factory.aspx</id><published>2007-04-11T13:00:00Z</published><updated>2007-04-11T13:00:00Z</updated><content type="html">&lt;P&gt;One of the most basic uses of Object Builder is when we want to specify that certain objects should always be created as singletons.&amp;nbsp; For example, we may require that only one instance of a&amp;nbsp;DataAccess object should ever exist.&amp;nbsp; This can be specified by setting a policy, in this case a SingletonPolicy, that applies to all objects of type DataAccess.&lt;/P&gt;
&lt;P&gt;The following example demonstrates how this code might look, and uses the Object Builder to create a DataAccess object four times - twice with the singleton policy enabled and twice without.&lt;/P&gt;&lt;PRE&gt;Builder builder = new Builder();
Locator locator = new Locator();

// We need a lifetime container to keep references to the objects
// SingletonStrategy depends on this!
locator.Add(typeof(ILifetimeContainer), new LifetimeContainer());

// Enable singleton policy for DataAccess objects
builder.Policies.Set&amp;lt;ISingletonPolicy&amp;gt;(new SingletonPolicy(true), typeof(DataAccess), null);

SingletonPolicyDemo object1 = builder.BuildUp&amp;lt;DataAccess&amp;gt;(locator, null, null);
SingletonPolicyDemo object2 = builder.BuildUp&amp;lt;DataAccess&amp;gt;(locator, null, null);
Trace.WriteLine("Objects equal: " + (object1 == object2));

// Clear locator
locator = new Locator();
locator.Add(typeof(ILifetimeContainer), new LifetimeContainer());

// Disable singleton policy for DataAccess objects
builder.Policies.Set&amp;lt;ISingletonPolicy&amp;gt;(new SingletonPolicy(false), typeof(DataAccess), null);

object1 = builder.BuildUp&amp;lt;DataAccess&amp;gt;(locator, null, null);
object2 = builder.BuildUp&amp;lt;DataAccess&amp;gt;(locator, null, null);
Trace.WriteLine("Objects equal: " + (object1 == object2));
&lt;/PRE&gt;
&lt;P&gt;Running this code will show that the singleton pattern is used for the first pair of references, and individual objects are generated for the second pair.&amp;nbsp; The locator object contains weak references to the objects that are created, and when the singleton policy is in effect this is searched to see if this object has already been created.&amp;nbsp; However since only weak references are used, we need to create a LifetimeContainer to maintain strong references to the created objects and prevent them from being garbage collected.&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=2084409" width="1" height="1"&gt;</content><author><name>sthorne</name><uri>http://blogs.msdn.com/members/sthorne.aspx</uri></author></entry><entry><title>Changing the default using directives in Visual Studio</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/steve/archive/2007/04/10/changing-the-default-using-directives-in-visual-studio.aspx" /><id>http://blogs.msdn.com/steve/archive/2007/04/10/changing-the-default-using-directives-in-visual-studio.aspx</id><published>2007-04-10T10:44:00Z</published><updated>2007-04-10T10:44:00Z</updated><content type="html">&lt;P&gt;The other day I was working on a demonstrator application for the Object Builder framework, and adding a lot of new classes to my project.&amp;nbsp; Having to manually add &lt;EM&gt;using&lt;/EM&gt; directives for OB in every class didn't seem terribly efficient, so I set about finding how you can change the default C# class template.&amp;nbsp; I discovered &lt;A href="http://blogs.msdn.com/ansonh/archive/2006/02/22/537414.aspx" mce_href="http://blogs.msdn.com/ansonh/archive/2006/02/22/537414.aspx"&gt;this nugget&lt;/A&gt; in Anson Horton's blog - if you open &lt;FONT face=Tahoma&gt;%Program Files%\Microsoft Visual Studio 8\Common7\IDE\ItemTemplates\CSharp\1033\Class.zip, you can modify the class.cs file within that's used to generate all new C# source files - it looks like this:&lt;/FONT&gt;&lt;/P&gt;&lt;PRE&gt;using System;
using System.Collections.Generic;
using System.Text;

namespace $rootnamespace$
{
	class $safeitemrootname$
	{
	}
}
&lt;/PRE&gt;
&lt;P&gt;You can then add or remove the using directives you want at the top of this file, and save it back to the archive.&amp;nbsp; Finally run &lt;FONT face=Tahoma&gt;%Program Files%\Microsoft Visual Studio 8\Common7\IDE\devenv.exe /setup to refresh Visual Studio's template cache.&amp;nbsp; Now all new C# files you create should match your modified template.&lt;/FONT&gt;&lt;BR&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=2069325" width="1" height="1"&gt;</content><author><name>sthorne</name><uri>http://blogs.msdn.com/members/sthorne.aspx</uri></author></entry><entry><title>Pretty Patterns</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/steve/archive/2007/04/04/pretty-patterns.aspx" /><id>http://blogs.msdn.com/steve/archive/2007/04/04/pretty-patterns.aspx</id><published>2007-04-04T11:44:00Z</published><updated>2007-04-04T11:44:00Z</updated><content type="html">&lt;P&gt;The &lt;A href="http://msdn.microsoft.com/practices" mce_href="http://msdn.microsoft.com/practices"&gt;Patterns and Practices&lt;/A&gt; team here provide a host of industry tested guidance on software development for the Microsoft platform, as well as software factories, application blocks and reference implementaions.&amp;nbsp; The current project I'm involved with is examing the &lt;A href="http://www.codeplex.com/smartclient/Wiki/View.aspx?title=Composite%20UI%20Application%20Block" mce_href="http://www.codeplex.com/smartclient/Wiki/View.aspx?title=Composite%20UI%20Application%20Block"&gt;Composite UI Application Block&lt;/A&gt; for creating rich smart client applications.&lt;/P&gt;
&lt;P&gt;This block allows the developer to easily create complex user interfaces from simpler reusable parts, and provides an MVP pattern implementation from which to develop.&amp;nbsp; Additional features include dynamic loading of independent but cooperating modules, event brokering and thread marshalling for loosely coupled communications, and a framework for pluggable infrastructure services.&lt;/P&gt;
&lt;P&gt;The Composite UI Application Block makes use of &lt;A href="http://www.codeplex.com/ObjectBuilder" mce_href="http://www.codeplex.com/ObjectBuilder"&gt;Object Builder&lt;/A&gt;, a Dependency Injection (DI) framework also originally written by the P&amp;amp;P group. Object Builder can be used to manage complex dependencies between objects and decouple objects in complex systems. There is a &lt;A href="http://msevents.microsoft.com/cui/WebCastEventDetails.aspx?culture=en-us&amp;amp;EventID=1032293738&amp;amp;CountryCode=us" mce_href="http://msevents.microsoft.com/cui/WebCastEventDetails.aspx?culture=en-us&amp;amp;EventID=1032293738&amp;amp;CountryCode=us"&gt;detailed webcast on Object Builder&lt;/A&gt; which is a good place to start understanding what it does for us and how it works.&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=2024603" width="1" height="1"&gt;</content><author><name>sthorne</name><uri>http://blogs.msdn.com/members/sthorne.aspx</uri></author></entry><entry><title>New job, new blog</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/steve/archive/2007/04/03/new-job-new-blog.aspx" /><id>http://blogs.msdn.com/steve/archive/2007/04/03/new-job-new-blog.aspx</id><published>2007-04-03T11:11:00Z</published><updated>2007-04-03T11:11:00Z</updated><content type="html">&lt;P&gt;Welcome to my shiny new blog! I've recently moved to MCS (Microsoft Consulting Services) UK from DPE (Developer and Platform Evangelism), so having talked about how great all these products are I now have to drink my own medicine and use them to solve real-world problems. My &lt;A href="http://blogs.technet.com/steveh" mce_href="http://blogs.technet.com/steveh"&gt;old blog&lt;/A&gt; is now retired, but shall remain preserved for the forseeable future.&lt;/P&gt;
&lt;P&gt;I'm currently working on a project for a large organisation in South Africa, and looking at a whole bunch of new technology that will enable their business to run even better. Stuff we're looking at include the whole .NET 3.0 stack (Windows Presentation Foundation, Windows Communication Foundation, Workflow Foundation), as well as the Composite UI Application Block, the Offline Application Block and the Smart Client Software Factory. Far too much to look at in one blog entry, but I hope to spend time on each of them in the coming posts.&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=2016614" width="1" height="1"&gt;</content><author><name>sthorne</name><uri>http://blogs.msdn.com/members/sthorne.aspx</uri></author></entry></feed>