Microsoft's latest .Net features are examined in an interview with Dan Waterbly, an accomplished .Net developer with the Washington State Digital Archives.
Dan Waterbly is a .Net applications developer for the Washington State Digital Archives, the first state agency built specifically for storing and accessing digital public records. The Digital Archive is a "100% Microsoft" shop where the most current .Net features are explored in a data-centric production environment. In this interview, I ask Dan about the nature of the latest development tools from Microsoft and his experiences using them in practice.
MC Press: Dan, as an overview, does .Net 3.0 replace .Net 2.0, or do you have to have 2.0?
Dan: You have to have 2.0. .Net 3.0 uses the same architecture and is really just a bunch of classes added on to 2.0. It doesn't replace anything; 3.0 runs on the 2.0 architecture.
MC Press: The features included in .Net 3.0 seem to be some of the same elements that didn't make it into Vista when it was released. There are four listed features in .Net 3.0 documentation: Windows Presentation Foundation (WPF), Windows Communication Foundation (WCF), Windows Workflow Foundation (WF), and Windows Cardspace. So to begin, what can you tell me about Windows Presentation Foundation?
Dan: Vista's look--you know, the whole UI change and the new aero look--is much more attractive, with the glossy look and glass background, and [Microsoft] has made it so you can develop much more graphic-intense applications compared with WinForms, which are pretty basic. Not that Microsoft is going to get rid of WinForms anytime soon, but WPF is another option you can go with.
MC Press: Well, what's the difference between a WPF application and a WinForms application?
Dan: The UI controls are different and more flexible, and WPF is XAML-driven. WPF uses a markup language to dictate how your user interface is going to look. WinForms is the classic Windows look, like an application you create in pre-2008 Visual Studio versions. With WPF, using XAML, you can create Windows applications like you would Web pages, with markup language, and basically code against that. It's kind of like ASP.Net, where you have a better separation between the application logic and the presentation logic.
[Microsoft's] Silverlight comes out of the WPF. Silverlight is a plug-in like Flash that gives you a subset of WPF on a Web browser. So you can develop some rich-client stuff for the user.
MC Press: What is WCF, or Windows Communication Foundation?
Dan: Whenever you talk about WCF, you're dealing with some service-oriented architecture where you're providing some kind of service that will be consumed by one or more clients. The consumers can be anything. They can be Java-based applications, or they can be .Net applications or Python applications. Anything that can consume a Web service can connect to a WCF service, assuming that the WCF service has the appropriate endpoints configured. The problem with previous versions of .Net is you could have a variety of transport mechanisms that could communicate with a variety of consumers. The problem with all that is you would end up having many different sets of code that all do the same thing. WCF combines all that so you write the code once and specify how [the clients] will consume the service, and that's all done through an endpoint.
MC Press: What's an endpoint?
Dan: A WCF service uses a configuration file to dictate the endpoints to use. An endpoint consists of an address, binding, and contract (ABC). The contract dictates what methods in the WCF service may be called by the consumer. The binding defines the transport mechanism, and the address dictates where the service can be accessed from.
MC Press: So the contract part of the endpoint is similar to the public methods available from a Web service?
Dan: Yes. You know how on a Web service you mark [a function] with a WebMethod attribute? With a WCF service, you create an interface and you mark it with an OperationContract attribute. Then you create a class that implements that interface; this is where all your business logic is, and every method you specified as an OperationContract will be accessible to the clients that are consuming your service.
Also with WCF, you don't have to run your application on IIS like you did with a Web service. You can run it in a Windows service and specify how the endpoints work, and it will create your server for you and communicate that way. It's called the "service host environment." You can run it in a Windows form application or as a Windows service, anywhere a .Net executable can run so you don't get all that IIS overhead.
MC Press: Let's talk about Windows Workflow Foundation. Did I notice it's abbreviated as "WF" rather than "WWF"?
Dan: Yes. As I heard it--and this may be just a rumor--Microsoft wanted to use the abbreviation "WWF," so they went to the World Wrestling Foundation and said, "Hey, can we use it?" and they said, "Sure, we don't care." So they did. And apparently the next day they received a cease and desist order from the World Wildlife Fund, and that's how they named Windows Workflow Foundations as "WF." The World Wrestling Foundation failed to tell them they fell into the same problem when they changed from being WWF to WWE.
What Workflows does is it allows you to create a flowchart or a process diagram describing what you want your application to do. I know from my work experience it's been a nice tool from a boss' perspective, where they don't understand code but they can look at the diagram and understand what it's doing.
Basically, Workflow consists of multiple "activities" that are tied together. Through variables, what [Microsoft] calls "dependency properties."
MC Press: It sounds like a transaction as we know it on a platform like the iSeries.
Dan: Well, yeah, you can do things transactionally, and you can also do things in a compensatable way. Out of the box, Workflows give you a number of different activities. One of the activities is the transactional scope activity. You can include a transactional scope activity in your workflow diagram, and within that activity, you can link together other activities. If one of the activities in the scope fails, the whole transaction is rolled back. It's a total atomic process, and it takes very little code from the developer.
WF doesn't, however, reverse everything. For example, if you have an activity that does an FTP transfer and another activity that makes database calls, and one of the activities fails, [WF] will roll back the database calls, but it won't roll back the file that was uploaded.
There are ways where you can write your own instructions to reverse activities any way you want. There's a lot of flexibility in there, but I think it gets complicated when you want to start doing that stuff.
MC Press: What have you observed when using WF in a production environment?
Dan: One problem I've run into is running a transaction against multiple data sources. So let's say you have two databases that you're working with, where one might have metadata and one might have binary objects, and you have a lot of transactions that run simultaneously. You either run into deadlocks or you run into issues with the Microsoft Distributed Transaction Coordinator. We ran into that firsthand. And we tried to deal with it in a couple of different ways.
In the transaction scope, you can set isolation levels, and basically an isolation level dictates what data is accessible to other processes at the same time that this transaction is running. So you can set it to serializable, meaning it runs on its own, and whatever it's working on, nothing else has access to. That's going to put the most locks on the database. But you can use a lower isolation level, and that will produce fewer locks, and it will also allow dirty reads, so if something in that transaction fails, you could get a rollback, and a user may be looking at phantom data, data that was there but got rolled back later.
We had 40 servers, each running eight instances of WF, so that's 320 workflows running at once, and all of them have their own transaction scopes, and it killed our production speed. We got many errors regarding the Distributed Transaction Coordinator and database deadlocks. So instead of using the transaction scope, we used compensatable activities, where you write your own rollback code for your custom activities. You lose the transaction scope, but you gain the benefit of undoing what the activities did.
MC Press: What can you tell me about the fourth feature of .Net 3.0, Windows Cardspace?
Dan: Cardspace is a digital identity in the form of a cyber card for use on the Internet that could be used to take the place of passwords or other authentication mechanisms. I question how useful it is, though, because of problems with it on Linux and Mac platforms and a lack of support on early versions of Windows.
MC Press: Well, how does Cardspace work?
Dan: It's like when you go to the store and buy something with your credit card and you're asked to show your photo ID to confirm your identity. What happens is, you go to a Cardspace Web site; your Windows machine will pop up and say either create a card or use an existing card. So if you already have a card for the site, you just pick your card, and they say, "OK, we know who you are now because you've given us a token identifying yourself." You don't have to log in. You don't have to do anything.
MC Press: What if someone else is using your machine?
Dan: Right, yeah. It's one of those [physical security] things. But Cardspace is linked to your Windows user account, so if you log in under your account and no one else can use your account, then you're OK.
MC Press: .Net 3.5 is available now. What's in there?
Dan: LINQ (Language Integrated Query) and there's some ADO.Net stuff that works with LINQ. You can use LINQ to query a SQL server. What I find most impressive with LINQ is you can write SQL-like queries against XML or any collection of objects that are enumerable in the .Net Framework.
Also AJAX (Asynchronous Java and XML) is now embedded in .Net 3.5, and you don't have to download it separately. AJAX allows you to do partial Web page updates and gets rid of the flicker when you go to pages. I have heard that AJAX is actually slower but the way the page responds to the user makes it seem faster. I personally think it is faster.
MC Press: Are all these features--.Net 3.0 and 3.5--included with Visual Studio 2008?
Dan: Visual Studio 2008 provides the 3.0 and 3.5 framework right out of the box. With 2005, you need the extensions. So if you have 2005 and the extensions, that should work, too.
MC Press: In your opinion, what's the best part of .Net 3.0?
Dan: Windows Workflow. If you have a complex transaction, [WF] breaks it up in such a way that it's easy to understand. It's so much easier to look at a diagram to see what's happening than it is to trace your code. The activities are so modularized and can be used in multiple applications. It's flexible, easy to understand, easy to learn, and easy to use.
MC Press: With all that said, Dan, what do you not like or are disappointed with in .Net 3.0?
Dan: The biggest thing I haven't liked about .Net is the way the database interactions go. It seems like it takes a lot [of effort] to insert a SQL parameter, and set your parameters up, and execute a stored procedure. You know, it's just a lot of code to do it. You can use the Enterprise Library to make it quicker and easier, but it would be nice if they would just build that into the Framework so you don't have to download another library, register it in the GAC, and suffer through potential deployment issues.
I was also hoping [Microsoft] would improve "click-once" so that it didn't require that you use a certificate that expires in a certain amount of time. The idea behind click-once is that updates can be deployed really easily, but when your certificate expires, that defeats the process.
MC Press: Thank you, Dan.
MC Press Online