# Wednesday, October 01, 2003

Here are the presentation slides from my Test First Programming with .NET talk at the .NET London user group.  As I finished the talk, where I was demonstrating the Nunit and the NUnit Addin when the organiser said the guy who wrote it, Jamie Cansdale, was in the audience.  Talk about the choir preaching to the minister!  Luckily Jamie is a really nice guy.

 

We had a chat at the pub afterwards where Jamie said he understood my concern that the Nunit addin didn't have the 'green bar' of the original GUI.  He lamented that his girlfriend didn't really understand the work he did (a common problem in development), but that she did understand the green bar.  In my talk I shared that both my wife and mum know about the green bar.  I compare its affect to the sound of a bell to a Pavlovian dog. Jamie said he'd had to switch back to the GUI after the addin broke when Nunit was upgraded, and it made him realise he missed the green bar as well!

 

The good news is that Jamie's working on a way to provide a view of the tests inside Visual Studio, so as part of these changes we may see the green bar appearing in the Addin.

posted on Wednesday, October 01, 2003 12:04:11 AM (GMT Daylight Time, UTC+01:00)  #   
# Tuesday, September 30, 2003

I was reminded of mind mapping after reading Tim Sneath's blog.  Last week I did a bit of Google and found a free mind mapping tool called Freemind (it’s written in Java but still has a decent UI response time!).  The keyboard shortcuts (INSERT for a new node, arrow keys for moving around, F2 for editing) make it very quick to use - I'm even thinking of using it for some talks at the PDC.

 

I've been using it for the last the last week to structure notes for an article, a review of the Extreme Programming Refactored book (review coming!) and even for TechEd talk that I've been listening to.  Here's a mindmap I did while I read recent articles on Test First development, for my talk at the .NET London User Group:

posted on Tuesday, September 30, 2003 11:47:02 PM (GMT Daylight Time, UTC+01:00)  #   
# Monday, September 29, 2003

Just as I was singing Ingo's praises in the last posting my SharpReader icon turned yellow with news of Ingo's a new MSDN article on role-based security with WSE 2.0.  The article is mostly on using X.509 tokens together with roles and policy files.   The latest project I worked on used the WSE custom token managers to authenticate a SAML token as well as a custom XML token (a substitute for the ASP.NET Session Id HTTP Header, but for web services).  However, I wasn't sure whether you could use the same technique for X.509 Certificates as this seemed to be handled automatically by the WSE framework. 

The solution Ingo demonstrates is to derive a class from WSE's X509SecurityTokenManager and override it's AuthenticateToken method, calling the WSE implementation after doing any custom code, as follows:

public class X509RoleBasedSecurityTokenManager:
  X509SecurityTokenManager
{
 protected override void AuthenticateToken(X509SecurityToken token)
 {
    base.AuthenticateToken(token)
    // do some custom work, like setting the token.Principal
 }
}

Once a TokenManager's authenticate (for binary tokens) or validate (for Username tokens) method has been fired (it's hooked up using the AppDomain's config file, usually the web.config file, or using WSE Visual Studio add-in) then the policy file is applied.  This allows you to make declarations in the policy file about the roles the authenticated/validated user must be in to access the method, without having to write any code on the [WebMethod].  Ingo uses the WSE Policy Editor tool rather than writing the Policy XML by hand (good choice), but just to make it real, the policy file would have the following:

<wsp:Policy wsu:Id="CertificateRoles" xmlns:wsp="http://schemas.xmlsoap.org/ws/2002/12/policy">
  <wsse:Integrity wsp:Usage="wsp:Required" xmlns:wsse="http://schemas.xmlsoap.org/ws/2002/12/secext">
    <wsse:TokenInfo>
      <SecurityToken xmlns="http://schemas.xmlsoap.org/ws/2002/12/secext">
        <wsse:TokenType>wsse:X509v3</wsse:TokenType>
        <wsse:Claims>
          <wse:Role value="Accountant" xmlns:wse="http://schemas.microsoft.com/wse/2003/06/Policy" />
        </wsse:Claims>
      </SecurityToken>
    </wsse:TokenInfo>
    <wsse:MessageParts Dialect="http://schemas.xmlsoap.org/2002/12/wsse#part">wsp:Body()</wsse:MessageParts>
  </wsse:Integrity>
</wsp:Policy>

This snippet defines a policy that says a soap request must contain an X.509 certificate security token that plays the role of Accountant in this application and that the soap:body of the request must be digitally signed with this certificate.

As I've mentioned before, this is is a great idea as it separates the code from the security settings

In the article, Ingo maps from the incoming certificate to some server-side certificate-role mappings to look up the roles that the user (represented by the certificate) is authorised to play in the application.  In his case he stores mappings between the certificate thumbprint (think Certificate Id) and roles in the configuration file.   I was thinking that it would be better to carry the role information inside the XML that represents the X509 binary security token (for example, SAML tokens have a collection of attributes that can be used for this value).  Perhaps it is better that each application map the certificate to local application roles as Ingo demonstrates rather than carry these with the tokens.  If the roles are defined with the tokens it means the issuer/creator of the tokens has to understand what roles the application's roles, which might be too tight a coupling between the token issuer and the application.

This was another good article from Ingo (he's certainly got his finger on the pulse.  I wonder if WSE and Service Oriented Architectures are part of his new book?).  It's great to see more articles on using WSE 2.0.  I can't wait for the other articles that Matt Powell mentioned.

posted on Monday, September 29, 2003 11:43:04 PM (GMT Daylight Time, UTC+01:00)  #   

One of the questions I've had with .NET is where has the COM Scripting Control gone.  Tonight Ingo Rammer helped me see the answer - there's no scripting control, but there is the ability to dynamically compile code.  So instead of using VBScript or JavaScript back in the land of COM, it's not possible to use and .NET language (VB.NET, JScript.NET) to script the application.  This is both a plus and a minus (it's more powerful, but also hard to learn to user).

Check out Ingo's presentation on Extensible Application with Scripting, CodeDom and Reflection.

posted on Monday, September 29, 2003 11:04:25 PM (GMT Daylight Time, UTC+01:00)  #   
Here's an article I found that shows the usefulness of .NET decompilers such as Reflector.  Jason Bock has an article on AngryCoder showing a situation where the .NET Framework can through an exception while getting the value of a property.  He was using ASP.NET to retrieve the HTTP Referrer and found that it was throwing an exception.  His code looked like:

if(this.Request.UrlReferrer != null)
{
    //Use the property's value.
}

Using a decompilation tool it's clear that the UrlReferrer property is doing some lazy evaluation of a URI member variable that represents the referrer.  The problem is that the .NET code is checking for the wrong type of exception.  If the URI object experience a problem in its constructor (such as a null or empty referrer value) then the documentations states that a NullArgumentException or a UriFormatException will be thrown.  However, the actual code only catches an HttpException:

try
{
   if (text1.IndexOf("://") >= 0)
   {
      this._referrer = new Uri(text1);
   }
   else
   {
      this._referrer = new Uri(this.Url, text1);
   }
}
catch (HttpException)
{
   this._referrer = null;
}

This is a downside of not having Java style exceptions, where each class must declare which exceptions it might throw and the compiler checks that all calling code handles it.  Describing the exception in the code is not a foolproof way of doing it.

Jason's article was on .NET 1.0, but it's still a problem in .NET 1.1.  Shame, Microsoft, shame ;)

posted on Monday, September 29, 2003 10:48:31 PM (GMT Daylight Time, UTC+01:00)  #   
# Friday, September 26, 2003

It's been a busy week - Extreme Tuesday Club, Patterns study group, and now today, some great news about some 'alpha software' that's coming into my life.  I'll put up a review of the Extreme Programming Refactored soon - it's a great book.

posted on Friday, September 26, 2003 2:52:16 AM (GMT Daylight Time, UTC+01:00)  #   
# Monday, September 22, 2003

Suzanne Cook is a Microsoft developer who works on the assembly binding code within the .NET Framework.  She writes some fantastic blogs, right up there with Chris Brumme (though thankfully not as long!).  Fumiaki agrees that her content is top quality and that she's prepared to go out of her way to help solve problem, including replying to email on a Sunday night.

In a code review with Mark White from MCS last week we were looking at some code I'd written to dynamically load an assembly.  In the XP spirit of 'do the simplest thing that works' I had used Assembly.LoadWithPartialName to load in my assembly since I was working on a development version that wasn't strong named or signed.  However this is a bad idea because as Suzanne says, it's the pathway back to DLL Hell.  As she says:

Assembly.LoadWithPartialName() ... uses partial binding. ... A partial bind is when only part of the assembly display name is given when loading an assembly. ...  First, it calls Assembly.Load(). But, if that fails to find the assembly, it will return the latest version of that assembly available in the GAC.

So, in the end I changed to use Activator.CreateInstance.  This works with partial binding for now until I strong name the assembly when I can use the full assembly display name.  Here's a sketch of the code (minus the error handling):

// Get the type from the config file value
Type remoteAssembly = System.Type.GetType(remoteAssemblyTypeFromConfiigFile);
string assembly = remoteAssembly.Assembly.ToString();
string typeReference = remoteAssembly.FullName;
// Get an object handle to this type
ObjectHandle wrapper = Activator.CreateInstance(assembly, typeReference);
// Unwrape the object handle into the interface we need
IRemoteInterface remote = (IRemoteInterface)wrapper.Unwrap();

posted on Monday, September 22, 2003 8:56:55 AM (GMT Daylight Time, UTC+01:00)  #   
# Friday, September 19, 2003

One final post before flying to Scotland to climb Ben Nevis.  From Mehran again, a Catalog of Non-Software Examples of Design Patterns.  A fantastic explanation of design pattersn with reference to real world situations rather than UML and class diagrams.  Definitely a useful resource for our study group.

posted on Friday, September 19, 2003 2:02:16 PM (GMT Daylight Time, UTC+01:00)  #   

Here's a book that looks interesting: Extreme Programming Refactored: The Case Against XP (courtesy of Mehran).  It seems to be based on an article availabe on the Software Reality website. I think its a positive step to see some critical reflection on XP, as I've had too many conversations about XP that sound like religious discussions.  I've ordered the book, but based on the article it looks pretty funny and as if it has some interesting points (can a customer afford to let a good person spend 100% of their time with the XP team?  How does pair programming allow a developer to think and reflect and achieve a state of flow necessary to understand some problems?).  Should make the next Extreme Tuesday Club meeting interesting ...

posted on Friday, September 19, 2003 11:36:30 AM (GMT Daylight Time, UTC+01:00)  #   

Based on my referrer logs it seems there was a lot of interest in my post on Indigo yesterday.  Spurned on by Don Box's suggestion, I've trawled the session outlines for the PDC to come up with these cheat notes:

Design goals:

  • Help ISVs and corporate developers, deploy and administer Web Services

  • Provide a simple declarative model that allows developers to get started quickly and a powerful object model that allows developers to get ‘down and dirty’ where they need to.

  • Provide an implementation of the WS protocols.  It will extend the areas that WSE is covering today such as Security, Address and Policy as well as adding support for the areas WSE doesn’t cover – Reliable Messaging and Transactions

  • Bring together the best of .NET Remoting, MSMQ, ASMX and .NET Enterprise Services (I’m thinking Pub/Sub Events come to mind as something missing from the current web service offerings)

  • Extend the security of web services (who thought that TrustBridge had gone away?)

Product details:

  • It’s based on a small set of concepts, interfaces and rules

  • It has a unified model and runtime for building connected applications on the Windows Platform

  • Work in various infrastructures such as peer-to-peer, intranet, internet and b2b and in different configurations (single node, web farm)

  • It’s a message bus

  • Security support is integrated into the product with a model that will work across different trust domains and supports extensible authentication, authorisation and token frameworks

  • It will have improved serialization support – making it easier to import and create schemas and control the serialization process

What’s in the box?  What will the code look like:

  • Ability to configure functionality through configuration files (see WSE and the WSE Visual Studio add in-for background)
  • Supports a declarative model for common cases (think attributes like WebMethod) as well as an object model for dropping into the infrastructure (think pipelines and WSE filters)

Marketing hot air:

  • Indigo will "scale without limit" - I love this one.  Surely there's a PowerPoint wizard that can catch these kinds of overgeneralizations?

  • Don Box: Indigo is a "state of mind"

  • "Web services are the foundation for the way developers will build distributed applications going forward"

posted on Friday, September 19, 2003 10:12:08 AM (GMT Daylight Time, UTC+01:00)  #   

Here's Alan Cooper again, talking about the costs of software development.  I like Alan Cooper, he reminds me of a Michael Moore of Software Development.  He talks loud, is funny and interesting and I belive that he's fighting the good fight.

He invented the visual forms designer for Visual Basic and has written some excellent books on how to design visual interfaces and who should do the designing( the title "The Inmates Are Running The Asylum" provides a hint that he doesn't think programmers should be designing).

His latest article isn't as powerful as some of his previous ones (read from one angle it sounds like a sales pitch for companies to spend more on training and consulting from his company), but he does  make the following useful points:

  • Companies need to spend more on designing and programming, not less.  Programming and design are long-term fixed costs not variables ones.
  • Many management ideas are a carry over from the industrial age, which he believes is innapropriates "No company can treat programmers the same as a factory because programmers demand continuous attention and support"
  • I like his definition of Softare architecture: "the human-design part of programming that studies users, defines use scenarios, designs interaction, determines form, and describes behavior".
posted on Friday, September 19, 2003 9:15:19 AM (GMT Daylight Time, UTC+01:00)  #   

Eric Gunnerson is asking whether they should change the default behaviour for displaying forms in Visual Studio so that when you double click on a file in the Solutions Explorer it opens either the code window or the form design window based on the way you last viewed the file.

I think he should definitely go with this idea.  I'm finding it so frustrating that the .asmx web service files are always opening on the designer view and I have to keep remembering to right-click or choose 'view code' from the hyperlink displayed on the designer.  I can't say much about straight forms as I haven't worked on a project that uses them heavily yet, but definitely for web services, defaulting to the format last viewed is an improvement.

posted on Friday, September 19, 2003 12:27:21 AM (GMT Daylight Time, UTC+01:00)  #   

Wow, this is cool, I just discovered through examining my referrers that Mehran Nikoo has a blog as well. This is great timing as I was just thinking 'I wish Mehran had a blog'.  Subscribed.   

Mehran is a switched on developer (he's taking holidays in order to come to the PDC, there's someone who knows who's managing his career!) who gave a great presentation on SOA (where are the slides Mehran?).  Mehran and his colleague Edward have written a number of good articles on developement on their company's site. 

He's also volunteered to provide a location where we can meet up and discuss the GoF Design Patterns in .NET (I know it's old school now that SOA is in favour, but they're still important within the right locations).  As he says, if you're in London and want to be involved, send us an email

posted on Friday, September 19, 2003 12:03:26 AM (GMT Daylight Time, UTC+01:00)  #   
# Thursday, September 18, 2003

I had an enjoyable day today working alongside Mark White, a consultant (and all round clever guy) at Microsoft in the UK.  Amongst other topics, Mark asked me a great question about the difference between Extreme Programming and Agile Development.  I said that I thought the fundamental difference was that XP was based on a more prescriptive set of practices (Test First, Planning Games, Paired Programming etc) whereas Agile Development was more a philosophy (based on focussing on the people issues of software development and doing things that worked).

At a drinks event tonight I spoke with a developer from ThoughtWorks who backed up my idea.  He said that one of the challenges was that Banks and Finance companies didn't like the idea of doing anything 'Extreme' so Agile was a better way of describing it.

I was interested to hear though that ThoughtWorks mix their Agile approach with large-scale multi-national development.  As the Agile Manifesto says, an Agile approach is about individuals and interactions over tools and process and customer collaboration over contract negotiation.  One of the key points of XP seems to be about communicating and talking with people, both within the team and between the team and the customers.  It strikes me that these principles may be challenged by large-scale projects worked on by geographically disburse teams (even if, as the ThoughtWorks developer said 'they are all clever people').

I also think there are great challenges with doing an XP approach on large teams.  In order for this to work I believe there has to be an overriding architecture that lets the large project act like lots of small teams.  To me large-scale projects with teams in different countries make it very difficult to practice agile or Extreme Programming.  Still, it's interesting watching ThoughtWorks as a test bed for Agile methods on large scale projects.

Mark also mentioned that the Microsoft Solutions Framework (framework, not methodology) could still add something to XP or Agile approaches with it's notion of the Team Model.   I particularly agree that these approaches could be improved with the role of Program Manager, but perhaps that's just my bias.

posted on Thursday, September 18, 2003 11:52:38 PM (GMT Daylight Time, UTC+01:00)  #   

Keith Ballinger reveals why he's been busy lately - Bill Gates demos interoperable web services between Microsoft and IBM with an application that:

"links automotive parts suppliers, manufacturers and dealers via Web services that use new specifications to ensure security, reliable messaging, and transaction support." here

MSDN seems to have an excellent article that describes the application used in the demo (and more on the practical implementation of SOAs) titled Secure, Reliable, Transacted Web Services: Architecture and Composition. Omri Gazitts has more about the demonstration. 

Reliable messaging and transaction support are obvious features not covered by the current WSE 2.0 implementation.  I think reliable messaging is particularly important.  For example, the project I'm working with at the moment uses web services to poll a database to see when changes occur.  Reliable messaging would allow the web service to notify the client via a message when new data was available.

posted on Thursday, September 18, 2003 11:35:00 PM (GMT Daylight Time, UTC+01:00)  #   

Update: I've written a more complete set of notes of what I think Indigo is.

Ah, the fun of trying to guess at a new technology before it arrives.  It feels like the marketing buzz that surrounds a new film - the intense focus and speculation before an opening night.  Steve Maine is trying to figure out what Indigo is, Christian Weyer has a turn as well.  Don Box tells us it's a 'state of mind', which makes Steve think its a Zen-thing

I thought Don Box's talk on XML at TechEd 03 was the most revealing where he said the WS-* specifications are being created to support a messaging platform and bus (made me think of TIBCO) for the enterprise.  I think that Indigo will continue to support these specifications, perhaps adding wider infrastructure support and an improved object model for developers to access these features.  In terms of the object model, I believe that WSE 2.0 TP gives us a good idea of what will be involved.  It's interesting two that the pipeline processing model on WSE 2.0 is actually an approach to Aspect Oriented systems, where the Aspects are the pipeline filters.

Just my 2c worth.

 

posted on Thursday, September 18, 2003 8:03:04 AM (GMT Daylight Time, UTC+01:00)  #   
# Wednesday, September 17, 2003

I got these two books last weekend and both are excellent:

C# Data Security Handbook - a great read going through all of the support for data encryption, digital signatures and certificates in both .NET and the CAPICOM.  Full of excellent code-samples and useful explanations of the background theory.

Professional Design Patterns in VB.NET: Building Adaptable Applications - a good overview of the design patterns in .NET.  I would have preffered it in C# but it's easy enough to convert.  The start goes through about half of the GOF patterns and shows how to implement them.  The rest of the book deals with how patterns might help in different architectural tiers.  There's a good coverage on creating abstract classes for ADO.NET which allow you to use them without having to use a specific data provider.  I'm hoping to use this as an aid to a study group in future.

posted on Wednesday, September 17, 2003 10:07:52 PM (GMT Daylight Time, UTC+01:00)  #   

I just got back from a day and a half at the VBUG Annual Conference.  It was a really good event for networking with some interesting and friendly developers.  It's interesting tracking what's happening to VB6 developers.  A slow drift to VB.NET seems to be a common story.  There's also still the tension between various styles of developers - those that are into architecture and the deeper workings of the system and those that are still concerned with string concatenation performance and how to use ADO.NET.

The drinks reception was an excellent chance to catch up with other speakers.  It was fun to hear Bill Vaughn's Microsoft War stories (like receiving a pager message to stop criticizing Access while he was still giving the presentation).  Tim Sneath was entertaining on the topics of blogs and did a commendable job of dealing with various developers’ comments on Microsoft.  He also recommended SourceGear Vault as the best source control tool.  I agree with him that Eric's blog is a good read.

I really enjoyed meeting up with Edward Garson and Mehran Nikoo from Dunstan Thomas who did a useful presentation on Service Oriented Architecture.  They revealed that they'd had a social gathering recently where they'd watched Don Box's presentation from the XML Dev-Con.  I revealed that my mum knows who Don Box is after seeing those videos.  These guys did a good job of joining the dots on what I've seen and read about recently.  The big revelation was the idea of having a Service Agent in the Data Access layer of one application managing calls to Web Services provided by another application.

My presentation went down well, though I had been up late at night using Reflector to convert my demos from C# into VB.NET (Man, line continuation characters, automatic formatting around brackets and having to put the Inherits statement on a new line are a real drag!).  It was also a challenge to condense a two-hour presentation down into 60 minutes.  Many people came up and said they found it useful and interesting - security and web services seem to be a common problem (one guy I met had hand-rolled WS-Security in VB6 - it took all summer he said).  I also got two more booking requests for other regional VBUG groups.

  

posted on Wednesday, September 17, 2003 9:59:37 PM (GMT Daylight Time, UTC+01:00)  #   
# Saturday, September 13, 2003

I've spent more time this week installing components I've worked on with a team who are using them in their project.  This is a team of Java programmers who are moving across to .NET.  It's been interesting to see how difficult they are finding it.  Most of the problems are down to the way IIS/ASP.NET handle security on boxes that have been locked down, and the complexity of their configuration files (we spent 2 hours on a problem due to a typo in a type name in one of the configuration files).

On the security permissions, I think it's excellent that Microsoft ship their operating systems in a more locked down way, but if you don't educate developers about what is going on then what tends to happens is suddenly the Everyone user and other important users get permissions like 'Full Control' over the entire hard drives. 

On the config files,  I remember Alan Cooper mentioning how only an engineer could have designed a computer keyboard where potentially pressing one key could change/invalidate the actions of all others.  It's like that with the config files - they are really powerful, but a single mistyped character can stop the whole system from working.  It would be better if there was some way of viewing the information (e.g. WSE 2.0 has a nice Dev Studio plugin that presents a UI for the config file), validating it, or at least easily separating different classes of information (e.g. a mistake in my logging configuration is less critical than a mistake in the user account that ASP.NET runs under).

After accepting the need for greater education and improved design, I think that the attitude of developers plays a key role in dealing with these issues within a project.  It's interesting how one person's feelings of frustration, negativity or anxiety can sweep through a team.  For example, I was trying to solve a problem to do with security access and had someone sitting next to me saying 'this is crazy, this is way to difficult ...' which made it very hard to focus on solving the problem.  When the issue was finally resolved there was more talk about how ‘stupid’ the system was than on making sure they understood why it occurred and how it could be fixed in future.

One particular danger in teams is 'magic' or 'superstitious' thinking - the bafflement when something that wasn't working is fixed.  This can lead to a feeling of hopelessness within the team - 'It wasn't working, then we did lots of things and now it just started working again but I don't know why'.

Getting over the feeling of hopelessness is key.  The starting point is to work from the assumption that nothing magical is likely to go on.  When the feelings of anxiety start it's important to focus on letting these go and focus on through the problem rather than worrying about the position you're in ('damn, I need to get this working now').  It's important to work on a model for understanding the problem - describe how you think it should be working, look for areas where this might be wrong and propose hypotheses about what's going on. Also, avoid stating the obvious 'we're stuck and nothing we're doing is working'.  Finally when things work again it can be worth backtracking to break them again in order to understand exactly what solved the problem (e.g. after overcoming the security problem we spent some time reproducing it just to make sure that our solution worked and our understanding of the problem is correct).

Unfortunately, working on development projects is harder than it should be.  It requires a lot of knowledge and education to get things to work sometimes (which is why we can ask for the large salaries).  Attitude plays a large role in how smoothly a project runs.  It’s important to avoid feelings of panic and anxiety and hopelessness by focussing on understanding problems and learning more about how it is working.   Then on the larger scale, campaign Microsoft to improve user education, event viewer messages, configuration tools and tools that make it easier to problem solve what’s going on at the lower levels.

posted on Saturday, September 13, 2003 9:31:18 AM (GMT Daylight Time, UTC+01:00)  #