June 2005 - Posts

Imagination at work: auctioning a GUID on Ebay

How's this for inventive ways to make money without effort? Some funny, silly person is selling a GUID on Ebay!

Somehow, I wish I had thought of that :-)

with 2 Comments

Software Factory: The Guidance Automation Toolkit (GAT) for Visual Studio 2005

Visual Studio 2005 really is a dream environment for any serious .NET Solution Architect or Developer. The built-in designers, the great new CLR and the language extensions, super new controls etc. make designing and developing complex applications less of a hassle. And as you may have derived from some of my previous posts, I also really dig automation of mundane tasks such as daily builds, build verification tests and of course coding and documentation of Data Access Layers, collections and the like. Enter Microsoft's Software Factories initiative.

A Software Factory, basically, is any automated process that generates software; be it code, a model, a spec, whatever. Software factories make the process of designing and building software less error-prone, faster and easier, freeing us up to focus on the interesting bits. And one of the absolutely coolest new things in this area is Microsoft's GAT.

The Guidance Automation Toolkit (GAT)

This toolkit is a freely-downloadable package from Microsoft's Patterns & Practices Group. Currently still in an early CTP version, GAT makes extending Visual Studio 2005 a lot easier than using the traditional means -- i.e., creating Enterprise Templates or writing plugins that talk to EnvDTE and the like. With GAT, architects and senior developers create guidance packages for their teams, for instance to auto-generate code and documentation, to quickly implement common domain-specific design patterns, etc., all according to company or team standards.
     Without GAT, such guidance is hard to create. With the current version of GAT, it still isn't super-easy (some XML handcoding is still required) but it's already a big improvement and we can be sure that the RTM version is going to kick some serious butt.

GAT contains a set of tools which are really layers on top of Visual Studio's extensibility mechanisms -- actually, to be really purist, GAT builds on top of the Guidance Automation eXtensions (GAX), which form another layer of abstraction on top of Visual Studio's APIs.
For instance, using GAT it's easy to create wizards which connect to databases and auto-generate Data Access Layer (DAL) code, Business Layer code, database schema documentation, etc. In fact, one of the samples of GAT demonstrated at Tech-Ed this year did just that.

At the core of GAT are concepts such as "recipes", "templates" etc. A recipe is basically a template for a use case. Recipes consist of actions which create, modify or delete "artifacts" (such as code or XML) in Visual Studio. Recipes can be parameterized and the parameters' input can be fetched from the user (using wizards), XML configuration files, databases etc. You can group related recipes and templates in Guidance Packages and distribute them in your team or on the Internet.

Part of the GAT is T3, the templating engine with the cool name which will sadly be renamed T4 by RTM for reasons that are probably better left obscure. The T3 templating engine is similar to CodeSmith and uses a syntax similar to ASP's HTML/code mixing: embedding code between <# ... #> tags in output such as XML, HTML or code.

Resources:

 

with 2 Comments

Architecture and Code Generation

This morning, Scott Hanselman presented his rather interesting talk on Code Generation (ARC305). I have mixed feelings on the subject -- I love the idea of generating chunks of code but I usually loathe the quality of the code. On top of that, often generated code can't be modified or built upon easily. For instance, I love the fact that you can generate typed DataSets using the xsd.exe utility, but the code it produces is really bad and you can't add stuff to it, such as raising an event when a certain property changes -- which is what I like to do. Anyway, back to Scott's presentation.

The basic idea of straight code generation is to build a specification, or call it a domain model if you will, for instance in XML files. You then have these XML files parsed, maybe along with some code templates (think CodeSmith or RapTier again), producing source code or compiled output (as in the case of xsd.exe). The key to making it successful is to shape it to fit your development processes and the domain you're working in. Obviously, if you're building small smartphone apps your code-generation procedure and the output is going to differ from your missile guidance system project. So you can make the input format (the XML schema for the domain models) as simple or as complex as needed, and provide very complex and flexible or very simple input templates.

Of course, you don't have to limit yourself to generating source code. You can generate documentation and unit tests as well, possibly even Word documents (using WordML) or, why not, Excel sheets with statistics?

Personally, I like to work with automated build systems that generate compiled Help files too, by tweaking Visual Studio.NET's project files before compilation (so that XML generation is turned on) and running NDoc on those XML files after compilation. In addition to code-generating tools such as CodeSmith, I also like to use ReSharper's template functions to automatically generate properties that raise xxChanging and xxChanged events, check for null input and the like. That's code generation too, but not the command-line variety that Scott was talking about. Digressing again...

Scott raised an interesting point when he talked about using WSDL as your specification language. Yes, WSDL was originally created for specifying the public APIs of web services -- it stands for Web Service Description Language, after all -- but that doesn't have to keep you back. Why not just use WSDL's syntax to specify entity classes, data access operations etc.? All you have to do is leave out the binding part and the Web Service discovery part of the WSDL, or replace it with something more meaningful to your code generator.

What's also nice about Visual Studio 2005 and .NET 2.0 is the partial classes feature, which fixes, in a sense, the “I can't edit this generated code” problem. To put in code that can't be generated off your model, you can tweak your code generator to output partial classes and then add code in other files that together make up the final class.

Later this week there's a session planned on NHibernate, the .NET version of Java's Hibernate which claims to be able to generate entity classes and business classes off databases and custom models. A couple of Java guys I'm working with use Hibernate and they're experiencing real pains with it. It'll be interesting to see how far NHibernate goes, and if it really is the holy grail that can generate half of any client/server app's code... Stay tuned, more to come on that subject!

with 0 Comments

Visual Studio 2005, SQL Server 2005 and BizTalk Server 2006 will be released

... the week of November 7 :-). This was announced at Tech-Ed Orlando this morning by Mr Paul Flessner himself. Check out the launch website at http://msdn.microsoft.com/launch2005/ to stay up-to-date!
with 0 Comments

Sessions at Tech-Ed today: Exception handling, Mobile Development, Software Factories and Smart Client Architecture

I went to a number of Tech-Ed sessions today of course, some more interesting than others. DEV320, about Exception Handling Best Practices, I found really rather basic (of course it was a level-300), talking about the obvious practices of avoiding having to throw and catch exceptions when they're not really necessary, the cost of exceptions, rethrowing exceptions etc. The presenter did a good job of explaining these basics. He should know them pretty well, as exception handling is one of his priorities in the CLR development group.

Windows Mobile Development

Then there was the Windows Mobile development cabana talk -- a soft of informal talk targeted to a smaller audience -- which was kind of interesting. A couple of topics were covered such as developing using the emulator images (you can develop for Windows Mobile 5.0 now here at Tech-Ed; the emulator images for this new OS are available in the Hands-On Labs), using mobile controls in ASP.NET applications and the use of SQL Server Mobile (the new name of SQL CE) for database-oriented smart device applications. The coolness here is that you can synchronize and replicate SQL Server databases between your desktop/server and smart devices directly via ActiveSync.

Software Factories

One of my favorite topics as of late: software factories. The basic idea is that you find patterns in your software projects and pour them into a “factory,” i.e. a collection of code templates, configuration presets, reusable blocks etc. so that you can generate parts of your new applications automagically. The talk gave an introduction to software factories and there was a live demonstration of using a factory. If you're going to one of the international Tech-Ed events and you're into software architecture, this session is not to be missed!

The way Microsoft envisions software factories in Visual Studio 2005 is by using that tool's support for DSLs (Domain-Specific Languages and the upcoming Guidance Automation Technology, or GAT.

DSLs are abstractions of given problem domains and the solutions to those domains -- or rather, your solutions. You can compare this roughly to UML in sense of notation (class diagrams, use cases etc.) of the problem and the solution, through patterns. Visual Studio 2005 comes with designer support for DSLs and you can even create them programmatically using the DSL SDK. GAT then provides a “recipe“ infrastructure for building your apps step by step, as a set of Visual Studio extensions.

Basically, you open an application recipe (a software factory) in Visual Studio, you design the flow of your solution as a state machine on a drawing canvas in Visio/Rose style, and you connect the missing parts by filling in the code that does actual work. Some of the code will be generated by the DSL system based on templates (compare to CodeSmith and ASP.NET, because you're embedding code that must be run at code generation time between <# ... #> and <#= ... #> tags).

The speakers demo'ed building an application that allows users to complete an order. The code they generated used the UIP Application Block to manage how users navigate from one screen to the next, which is of course the smart thing to do. When data needed to be retrieved from a back-end system -- a web service of course -- they created a Web Reference proxy as usual and added a caching Service Agent on top. Data would only be retrieved from the back end if it was not already in the service agent instance's cache. And, yes, the service agent was auto-generated too, again based on a code template and some input from the developer. The generated code used the Caching Application Block. As Darth Vader would say, “Impressive... Most impressive!“

Yes, you can do it with other tools too

Of course, the basic ideas here are not new. You can use Visio templates today to come up with reusable general designs; you can use tools such as CodeSmith to generate code based on templates, including code that uses the Enterprise Library and the other Application Blocks. But in Visual Studio 2005 and the extensions these gentlemen demonstrated, it's all so nicely integrated with the IDE and wizards and designers make it much easier, saving us developers and architects time.

Software Factories are the Architect's Domain

I think that consuming software factories is for developers and that creating them is mostly work for the Solution Architect and the Senior Developer, based on code written in previous projects. It is their job to spot patterns in the enterprise's software designs and needs, and to extract those into a set of reusable factories and application blocks. Moreover, I think that while software factories are definitely another step in the right direction towards delivering 4GL's promise, the common problems related to reuse will resurface with factories: are people going to spend time to write code and create templates and factories that are actually reusable, and will they actually be reused? From experience I have learned that this is only true if reuse is enforced on the team by the Solution Architect, who must posess strong reuse and mentoring skills to drive this point home and to actually get it used by the rest of the team...


Smart Client Architecture

The final session I attended, or at least entered before I left 10 minutes later, was the one on Smart Client Architecture. This subject is “totally my bag,” to quote Austin Powers, and again I felt as if the presenters were dissing up old material that anyone can find in the Patterns & Practices materials. Anyway, I left the session quickly without waiting for any potential juicy bits to appear because I got tired of listening to the Buffalo Bill-soundalike onstage...

Well, I'm off to the reception now. Talk to you again tomorrow and keep those comments coming :-)

with 0 Comments

Total Coolness: Microsoft's (free) online Virtual Labs

Microsoft launched a really cool initiative today: the Virtual Lab. Using it, you can perform exercises such as those at Tech-Ed's Hands-On Labs from your own PC over the Internet.

That's right: via your Internet Explorer, you connect to a full virtual PC that has all the software installed you need to do the exercise you selected first -- for example, you may want to experience ClickOnce Deployment firsthand, or you may want to experiment with C# 2.0 without downloading and installing Visual Studio 2005 Beta 2 or the Visual C# 2005 Express Edition Beta 2.

The procedure is simple: register for free, select the virtual lab you want to try your hand at, open the PDF that guides you step by step (a good idea is of course to print it), then connect to your very “own” virtual PC over the Internet and start clicking away! You don't have to be afraid of f..., ahem, messing up because it's a virtual machine and it gets deleted after you've used it anyway. Run into trouble? Close your session and open another, fresh one.

Microsoft is putting a number of such virtual labs online and more are coming. I think it's the greatest idea since trialware!

with 0 Comments

Steve Ballmer's keynote kicks off Tech-Ed Orlando nicely

This morning Microsoft CEO Steve Ballmer's keynote speech kicked off Tech-Ed talking about the “New World of Work” as envisioned by Microsoft. This reminded me very much of the yearly internal-only Microsoft Technical Briefing (MTB) and Microsoft Global Briefing (MGB) events that I attended while at MS -- every year there's a new slogan such as “Realize Your Potential” etc., and they all boil down to the same thing: we want to create software that makes people's lives easier, tools that help them jump farther and with less effort. It's just like Apple's slogan a few years ago, “The Power To Be Your Best.”

Anyway, the current wave of potential-realizing new world of work stuff generally means better communication and connectivity. People want to travel, use software and devices etc. using a single identity, they want to know who they can reach and how, etc. This is nothing new really; it has been a central tenet of portals for years.

The key is, however, that the new tools make it easier to get there, or make it easier for developers to write software that gets people there. Microsoft's Live Communications Server is an example of the former, and Visual Studio 2005 is an example of the latter. What I'm really looking forward to, besides the full RTM versions of Visual Studio 2005, SQL Server 2005 and BizTalk Server 2006, not to mention Longhorn at some time, is actually using the recently-announced Windows Mobile 5.0. According to Steve, or should I call him Mr Ballmer, some 40 OEMs are going to ship devices based on this OS this year. In addition to that, we can expect Windows 2003 Release 2 this year too, and of course the 64-bit version of Windows 2003 is here already (if not, Microsoft put a bogus DVD in my event bag...)

.net is gaining momentum

Earlier this year, I heard from Microsoft Belgium that .net had surpassed Java as an enterprise development platform in Europe. Ballmer quoted some numbers, claiming a 43% market share for .net as developers' primary platform vs. 35% for Java. That's quite impressive, given that .net is much younger and that version 2.0 is still in Beta today. Part of that success is of course due to Microsoft's excellent marketing, but most of it, I think, to the sheer quality of the environment.

I've been coaching a couple of Java developers during their switch to C# for a while now, and they too realized the value of C#/.net quickly. Okay, Visual Studio.NET 2003 is not up to par with Eclipse, but Visual Studio 2005 definitely is. The fact that .net Beta 2 scores up to 200% faster execution time than IBM WebSphere 6 on Sun Microsystem's own WS-Test 1.1 benchmark also shows that it's far superior on the server.

Seeing that .net is a core technology in upcoming systems such as SQL Server 2005 and Longhorn, and seeing that it looks like it's going to get integrated into the other server products such as Commerce Server 2006 more and more, Microsoft's strategy and vision of interconnected systems based on managed code is starting to come together, and will provide a huge payoff soon...

with 0 Comments

Ready for Tech-Ed...

Well, Tech-Ed 2005 Orlando starts tomorrow, and I'm totally looking forward to it. There are a number of interesting tracks such as new trends in software architecture; mobile development; BizTalk Server 2006; 64-bit Windows; and of course mobile development using Compact Framework 2 and Windows Mobile 5. It's going to be an action-packed 5 days this week; luckily the attendees will get some party time at Universal Studios Orlando on Thursday night to relax the learning muscles.

I'll keep you posted about the tracks I follow, that goes without saying...

with 0 Comments