NZ .net Dude

Random thoughts from a kiwi .net developer

Service Factory Modelling Edition – part 2

Posted by Mark on July 14, 2008

In my last post, I went over a number of issues that my project team and I had with the Service Factory Modelling Edition.

One of the issues was with respect to the generated Entity-to-DataContract translator classes, specifically the fact that the generated class contains no “collection” translation method.

Now, it may seem obvious to some that there is a straightforward way to leverage the generated methods to achieve translation of an entire collection of entities to data collection types, or vice-versa, but not everyone finds it so obvious (at least, some on my project team didn’t find it obvious!! :) )

Ok, lets imagine we have generated a translator class for an Address entity and an AddressDC data contract type. You get the following two static methods (code removed for clarity):

public static BusinessEntities.Address TranslateAddressDCToAddress(DataContracts.AddressDC from)
{
    ...
}
public static DataContracts.AddressDC TranslateAddressToAddressDC(BusinessEntities.Address from)
{
    ...
}

Now, we also have a collection of address entities (stored as a List<Address>), that we want to translate into a collection in our data contract. The data contract has been designed using the modelling tools in the Service Factory, and our AddressDC collection has been modelled as a collection of type List also.

Basically, you loop through the collection you’re translating from and for each record, you call the appropriate translator method, like so:

List<Address> output = new List<Address>();

foreach (AddressDC addressDCItem in AddressDCColl)
{
    output.Add(TranslateBetweenAddressAndAddressDC.TranslateAddressToAddressDC(addressItem));
}

Ok, so the other part of this equation is making sure that we factor this well, and don’t write this code over again everywhere we want to use it. The most logical place to put this is to write it as a new method on the existing translator class.

Of course the thing to remember with this, and this is the issue I really had with the translator generation in the Service Factory, is that the translator is not a partial class, so we have to add code to the existing code file, and because of that, we need to realise that this code will be “removed” again if the translator ever needs to be re-generated.

Obviously we’re likely to want collection translators that go both ways, so there will be two new hand-coded methods. Therefore our final translator would look something like this (again, some of the code has been removed for clarity):

public static BusinessEntities.Address TranslateAddressDCToAddress(DataContracts.AddressDC from)
{
    ...
} 
public static DataContracts.AddressDC TranslateAddressToAddressDC(BusinessEntities.Address from)
{
    ...
}
Public List<Address> TranslateAddressList(DataContracts.AddressDCColl from)
{
    List<Address> output = new List<Address>();
    foreach (AddressDC addressDCItem in from)
    {
        output.Add(TranslateBetweenAddressAndAddressDC.TranslateAddressDCToAddress(addressItem));
    }
    return output;
}
Public DataContracts.AddressDCColl TranslateAddressList(List<Address> from)
{
    DataContracts.AddressDCColl output = new DataContracts.AddressDCColl();
    foreach (Address addressItem in from)
    {
        output.Add(TranslateBetweenAddressAndAddressDC.TranslateAddressToAddressDC(addressItem));
    }
    return output;
}

Please note that this code has been coded off the cuff, and has not been tested, nor even compiled. It’s there just to give you a general idea of what to do.

Mark

Posted in Architecture, Software Factories | 4 Comments »

Service Factory Modelling Edition – Part 1

Posted by Mark on July 4, 2008

In my last post I mentioned that I’d be writing a bit about the experiences I’ve had recently with some of the Microsoft Patterns and Practices Software Factories. On a recent project, I made the call to introduce the use of the Service Factory Modelling Edition, the Repository Factory (a.k.a. the Data Access Guidance Package), and the Smart Client Software Factory to my team.

To get the ball rolling, I’m going to begin with a bit of a discussion on some of the issues I found with the Service Factory Modelling Edition.

This list is a pretty exhaustive list of the things that tripped us up during the course of the project. I’m not having a moan here, because overall I think it’s a pretty cool tool, and I think that the P+P group did a damn fine job of the designers in particular, considering that this is pretty much the first version of the tool to include them.

  1. The model designers don’t support cut-and-paste of sub-elements (such as primitive sub-types on a data contract). So if you have a datacontract type, that is used in two different places, you can’t copy and paste, you have to create the second one from scratch.
  2. The designers for data contract and service contract do not allow the user to manually enter the type name for types that differ from the default “System.String” – have to use the type selector GUI instead (extreme level of user interface friction). This one caused me some aggravationsince in a lot of cases, I wanted the type of a contract member to be something other than string.
  3. When using the WCF Extension, the DataContract designer should support auto-increment or auto-assignment of the “Order” property of sub-types rather than defaulting to 0 for every newly added subtype, since it is necessary to have a unique Order value for every member.
  4. There is no support for nullable types in translators. For whatever reason, the Entity to DataContract type translator codegen and wizard do not like nullable types. I had some other issues with the translators also, chiefly the facts that a) they are NOT generated as partial classes, and b) there is no ability to generate a translator for collections of a given Entity/DataContract type. I’ll cover how I got around this in a later post.
  5. No support for tidily removing generated artifacts – translators, DC’s, Services, etc. There is no easy way to undo a “generate” – you have to manually delete the generated code if you remove or rename an item using the designers.
  6. There is no out-of-the-box support for WCF bindings other than wsHttpBinding and basicHttpBinding. You need to implement an extension to provide this support. This was annoying, but was pretty easy to sort out. I’ll outline this in a later post also.
  7. There is no way to reference types from one data contract model in another data contract model. If you have a data contract type defined in a model, and you want to use that same type in more than one place, then you can only do so within the same model. This leads to some of my models being overly large, with everything on the one model or, if you do persist in splitting things up into separate models (which I think makes perfect sense), then you end up with more than one copy of the type (one on each model), which is a real problem when it comes to code generation, and keeping the two (or more!!) models in synch with each other.
  8. No support for generation of asynchronous client proxy code. At one point I wanted to be able to generate an asynchronous client proxy, but I found that this was not supported in the Service Factory Modelling Ed.
  9. The out-of-the-box service host project is implemented as an ASP.Net web site. There is no support within the service factory for self-hosting scenarios, such as hosting services in a windows service (at least, I never found any). I will also cover my solution to this in a later post.

 

Again, as I said, I’m not criticising the Service Factory. I think it really made things easier on this project in particular, as we had a very junior developer join the team mid-project (she was from the customer’s development team in fact) and I think that without this tool, she would probably still be trying to get her head around the concepts involved in service development.

Mark

Posted in Architecture, Software Factories | Tagged: , | 1 Comment »

Its been a while!

Posted by Mark on July 3, 2008

Wow, ok so it’s been a while since I’ve posted anything! Well, I’ve got some material to post on so I’m going to be doing a few more over the next few days.

I’ve recently been working on a project where I’ve been using the MS Patterns and Practices group’s Software Factories, along with VS 2005, and I have some thoughts and comments on these that I’d like to share.

Hopefully what I have to say will be helpful to someone, since much of what I’m going to post relates to solutions I found to some fairly fundamental limitations in a couple of the factories that our team used.

In particular, I’ll be addressing workarounds for issues found in the Service Factory Modelling Edition, and the Repository Factory (or Data Access Guidance Package), along with general notes on our teams experiences with these and the Smart Client Software Factory.

So, as I said, hopefully someone reading will find this interesting, or even helpful…

Cheers
Mark

Posted in Architecture, Software Factories | Leave a Comment »

Managing Requirements with TFS

Posted by Mark on January 31, 2008

So, I’ve always felt that one big gap in software development tools generally was that there’s never really been a truly effective way of managing requirements, and tracing individual requirements through to the code that implements them.

Sure there are requirements management tools out there, for example, CaliberRM, but I’ve yet to see a good integrated requirements-to-code tracibility tool.

TFS does have the potential to offer this, with it’s work item tracking features, and the fact that work items can be linked to code changesets, builds, etc. But I’ve not been that impressed with this from a requirements management point of view, for a number of reasons.

 Firstly, the out-of-the-box process templates offer only a single approach to requirements tracking, using scenarios. This means that if you do things differently (Use Cases – similar to scenarios, but not really the same thing, features as part of an FDD process, or just plain ol’ numbered requirements in a word doc), you’ve got to either change the way you do things, or build something yourself to handle your way of doing RM.

However, I found a series of posts by Steve Lange on RM using TFS, which gives a good overview of the topic, from using out of the box TFS for RM, through to coverage of a number of the third party RM tools that are out there now providing integration with TFS. Steve also does a couple of good pros/cons summary tables as well. Read the series here.

Posted in Requirements, Software development Process, Team Foundation Server | Tagged: , , , , | Leave a Comment »

New job, new house

Posted by Mark on August 2, 2007

So despite my best intentions, I’ve slacked off from blogging again….however I have good reason this time – I left my old job at EDS and have started at Optimation as a .net Solutions Architect. On top of that, we’ve finally bought ourselves a house – up on the Kapiti Coast at Paraparaumu Beach….

So the work (or lack of it) at EDS was getting to me, and I decided I needed a change. Well, Optimation certainly is different from EDS!! They’re a small (compared to EDS) New Zealand based company, with something like 50 people in the Wellington office (myself included). For the moment, it’s meant saying goodbye to working on a laptop (though thats about to change), goodbye to Vista and Office 2007 :( , and goodbye to using Orcas/VS 2008 at work – just as the beta 2 release is made available too!! Still, I needed the change, and I can get my VS2008 fix at home, hopefully. Plus theres a chance I can convince my new boss to let me use it at work too… :D

Posted in General | 1 Comment »

More Orcas stuff

Posted by Mark on June 2, 2007

Just another quick post on Orcas, and in particular LINQ.

LINQ is obviously one of the buzzwords in .net at the moment, and I’ve been following it as the hype has been building…I have to say that to begin with my first thoughts were “well, it looks funky, but it’s never going to replace your standard ADO.Net SqlConnection, SqlCommand, etc method of data access”.

Now that I’ve looked into it a bit more, I’m prepared to admit that I’m wrong - it’s going to have a much bigger impact that I first thought. I’m going to be doing a lot of messing about with LINQ in particular to get a real good feel for how you use it, how it works, what you need to do to extend it, etc. That way, as an architect, I can be prepared to make a call as to how much use it will really be. My gut feel at this stage though is that LINQ could well be something that you’ll be wanting to use “everywhere”.

As I learn more about LINQ, I’m going to post my thoughts, but in the meantime, I want to pass on the source I’ve been using to learn about LINQ, in case anyone out there finds it useful. I’ve subscribed to Scott Guthrie’s blog, and he really is the man when it comes to getting concise overview information on LINQ. Scott seems to really have a talent for taking you to the right level of detail to be able to understand the subject at hand. Not too complicated, not too simple, his examples are really straightforward, and in my opinion, Scott’s blog is the best resource I’ve found yet for learning about LINQ, and other .net technologies as well. 

Posted in Orcas | 1 Comment »

Playing with Orcas

Posted by Mark on June 2, 2007

So at work I was asked to participate in our Visual Studio “Orcas” technology adopter program…Of course I said “yes” even though I thought the chances were slight that I’d be able to actually use it in anger on a project.

But what do you know? The TAP program hasn’t even really kicked off yet, and I’ve been using Orcas beta 1 for real for a couple of weeks now already, thanks in part to the multi-targetting (so I can use it in place of VS 2005 for .net 2 and 3) and the fact that it’s compatible with TFS 2005.

 I’ve been using it from inside a Windows Vista virtual machine which I’ve dedicated 1GB of RAM for.  My thoughts so far? Well, I’m planning to blog on a bunch of Orcas features as I use them, and form concrete opinions on them, but generally I’ve been impressed. The big thing is that it’s rock solid. Compared to some other product beta’s that I’ve used, Orcas Beta 1 is as steady as a finished product. Granted I’ve not really been going hard out to break it or anything, but compared to experiences with VS2005 betas, and betas of Vista and Office 2007, where even the beta 2 and RC releases were buggy in some cases, this has been a dream to use. 

 So, overall I’d have to say I’m impressed so far, to the point where I’ve come up with a few ideas of some little side projects to tinker with using Orcas. I’ll blog on some of those as I go too, hopefully.

Posted in Orcas | Leave a Comment »

Agile and CMMI – different?

Posted by Mark on March 19, 2007

So, a couple of days ago, I responded to a query on the NZ .net user group mailing list, around the difference between CMMI and Agile, what is TSP/PSP, etc. Seeing as how I work for an organisation where we have been CMMI certified (to one level or another) for 5+ years (and we’re going down the TSP/PSP path too….though I must admit I don’t know a hell of a lot about PSP and TSP myself), I felt sort of obliged to respond.

So, for the record, and given that no one disagreed with anything I said :) , here is a copy of my thoughts on the difference, what is Agile, what is CMMI, etc:

As far as my understanding of PSP/TSP goes, these are not software development processes, rather, they are personal and team productivity guidelines – ways in which you can measure and track personal and team productivity at a low level, and work as a result on making improvements where they are required.

CMMI is not a process in itself, rather it’s a set of standards you should follow to ensure that your processes are configured in a way that they are capable of maturing and improving over time. CMMI has a number of levels, which indicate where your organisation’s processes are along the maturity level. So, if you take MSF for CMMI Process Improvement as an example, you’re getting a process that is aligned to the “key practice areas” of CMMI level 3, which is in the middle of the range (the range goes from 1 (just starting out on the journey) to 5 (which represents a level of maturity where the processes themselves are rigorously managed and continuously being improved).

In terms of comparing CMMI to Agile, as I said, CMMI is not a development process per-se, but then neither is “Agile”. I suppose you could characterise an agile methodology as one where change is embraced, and reacting to change is built into the process itself. As a result, there tends to be less up front documentation done (why document everything to the nth degree, controlling document versions, etc, if it’s only going to change in a week?), and more focus is given to specific techniques for adapting to change as a project progresses. In contrast, a CMMI development process will take a different approach to change, managing it carefully, assessing impact of potential changes as they arise, documenting what was changed and when, as well as who by. A CMMI process will also require more documentation than many people might be used to because of the need to capture and analyse metrics in order to determine where processes might best be modified to achieve a higher quality result.

Having said that though, there was a great article from David Anderson (the guy behind MSF as seen in Team System) a while back discussing whether Agile and CMMI were mutually exclusive or not. So, could an Agile process also be certified as compliant with CMMI?? The conclusion was that yes it is totally possible. Here’s a link to that article…

http://www.agilemanagement.net/Articles/Weblog/CMMIandtheDeclarationofIn.html

Posted in Software development Process | Leave a Comment »

Team Foundation Power Toys saved my life!

Posted by Mark on February 22, 2007

…or at least, my Sanity!!

Anyone following my series about our efforts to build a custom process in TFS for our internal teams will know that I’ve begun by tackling the Work Item Type definitions first.

Without a decent GUI for doing this, it’s all XML, angle brackets, attributes and all…so, with 90+ fields, 13 states and 25+ transitions, theres a lot of cutting and pasting involved, to say nothing of the difficulties involved in managing a 1200 line long XML file in a glorified text editor.

However, for those like myself who are neck deep in the vagaries of the Work Item Type definition schema, help is at hand, for lo, Microsoft have released version 1.2 of the Team Foundation Power Toys. Big deal? Sure is, cos new in this release is a GUI ProcessTemplate editor. Having had a quick play so far with the Work Item editors, it looks to be something of a saviour for me at least. Gone is the endless cut-and-paste routine, replaced with a nice (? better than xml at least…) gui editor.

No more continual making a change, importing to a team project, and checking form layout, as it also includes a form “preview” in the editor.

And it’s even got a (DSL?) designer for defining workflow!!

Nice one! On a final note though, I had a bit of a laugh at the “Microsoft Pre-release Software License Terms” that governs this editor….it states “This software is a pre-release version. It may not work the way a final version of the software will. We may change it for the final, commercial version. We also may not release a commercial version.” and also “The term of this agreement is until 31 December 2008, or commercial release of the software, whichever is first.”….so, it might be released commercially, it might not…and if it is, it might be available before the end of 2008, or it might not. Oh, and if it’s not, then your license will expire anyway.

Last time I read a license agreement! J

Posted in Team Foundation Server | Leave a Comment »

TFS Work Item Customisation, and the TF26201 error

Posted by Mark on February 21, 2007

With the work I’ve been doing defining custom Work Item Types in TFS lately, I came across an interesting problem, to do with TFS’ TF26201 error, so I thought I’d mention it here, along with how I went about sorting it out.

So, having finished the first cut of the first work item type definition, I went to test it, and discovered that some when changing a test work item to certain states and attempting to save, Team Explorer would fail to save in the new state, with an error:

“TF26201: This work item has unsupported fields, or user does not have permissions”.

I googled the error (as you do) and didn’t have much joy. A couple of people found this problem when doing stuff with the W.I.T object model, but I couldn’t find anything about tracking down whats wrong when testing custom work items using Team Explorer. So, to figure out what was causing the problem, heres what I did:

 

  1. Edit the work item type definition file, commenting out all field rules in the “To” state, and upload back to server
  2. Try saving item to the new state, which should work now, as there are now no field restrictions in place for that state
  3. Uncomment all the field rules from the “To” state again, and again upload to server
  4. Open work item and try to save as-is, without changes
  5. Team Explorer will complain about specific fields, instead of the general error message
     

For the record, the reason I was receiving this error was because I had some fields in a couple of states with “<EMPTY />” rules, scoped to the STATE. Removing these fixed the issue, and I’m going to try scoping these to the a specific TRANSITION instead.

Posted in Team Foundation Server | Leave a Comment »