|
Hacking on Class Diagrams |
2005-04-30 |
|
Today I hacked on the Class Diagram functionality in Whidbey to allow rule-based generation of diagrams. Rather than manually dragging and dropping classes, I can now write a statement to build a diagram containing classes matching certain conditions. This is useful because it cuts down the work involved in creating a diagram, and allows the contents of the Class Diagram to be recalculated so any new classes or changes are picked up dynamically. Ever wanted to see a top-level view of your system that selectively includes things like:
If so, then read on... The background Since late 2004 I have been working on a project to build diagrams within Visual Studio which are linked to development artefacts using queries. The project is called Concern Maps, and provides a simple box and arrow visual language for modelling arbitrary "stuff" (e.g. patterns, architectures, source and related documents, cross-cutting concerns, etc...). The example below is a Concern Map representing a data access concern, with three "concepts": Data access classes, Order entity CRUD methods and Customer entity CRUD methods. The large orange boxes within this visual language can be annotated with query expressions, which are contained within the small paler boxes. These query expressions could be one of several languages, and at the moment I have implemented regular expressions (for selecting sections of text), file names (for selecting entire files), XPath and XQuery (for selecting program elements from an XML representation of source code), and several shortcut queries (to hide some common XPath or XQueries like "types named X" or "type implementing interface Y", see this post for a full list). The data access example above uses XPath and XQuery expressions to select individual methods and classes based on their properties. Query expressions are executed when a user double-clicks the associated box on the Concern Map. The matching artefacts (e.g. classes, documents etc) are displayed to the user in a tree view, and can be opened at the correct position within their file by double clicking the relevant node in the tree view. The example below shows the tree view that is displayed when double clicking the Data access classes shape within the diagram. What does this have to do with the Class Diagram? Until now I had been content to allow users to skip straight from the Concern Map diagram to the source code by clicking on the tree view. But while jogging this morning, I had a eureka moment - why not select classes into a Class Diagram? This improves the Concern Map experience by allowing users to hook into the Class Diagram editing capabilities. It is also a nice tweak on the Class Diagram, since the user can populate the diagram based on the properties of the code rather than manually enumerating types. This might not be a big deal when working with tens of classes, but once the number of classes gets into three of four figures it becomes a much more interesting proposition. I've roughed up a solution containing three projects to try to illustrate the capability. The solution looks like this:
I've also added a Concern Map the Acme.ConcernMaps project to represent the Manager / Widget relationship:
The Widgets query uses the Class Diagram language I put together today, and selects classes into a Class Diagram when it is evaluated. The expression 'InNamespace Acme.Widgets' is used within the query to select all classes in the Acme.Widgets namespace. Double clicking the Widgets node causes the Concern Map system to run this query and present one result to the user - a new Class Diagram file called temp.cd.
Double clicking this new file in the treeview loads it in the main frame, as shown in the screenshot above. It has also been added to the Acme.ConcernMaps project behind the scenes, so it can be loaded from there if the user doesn't have the Concern Map open.
I'll put together a screencast tomorrow that shows this running within the IDE. |
|
|
Tennis, v3 release, paper |
2005-04-24 |
|
I am going to be sore tomorrow - I played my first game of tennis in a long time (two years? I remember playing in Vegas in 2003) today. On the mental exertion front, I got v3 of my DSL tools project out the door today. The big change is the shift to a hybrid CodeModel / IL approach for building an XML representation of the solution in Visual Studio. This solves quite a few subtle problems and makes the tool a lot friendlier to use. I did have to counter quite a few mismatches between the CodeModel (e.g. source code) and IL names for things like constructors, class constructors, and explicit interface implementations, but it is working pretty well now. I also spent a couple of hours revisiting a paper I wrote in October 2004 which now looks like it will be published: I was suprised that it all pretty much made sense, even though I don't think I had written a line of code at the stage. Anyway, hopefully that paper will see the light of day before I get the urge to mess with it again. |
|
|
Must read |
2005-04-18 |
|
Using CodeModel |
2005-04-17 |
|
I spent yesterday altering my DSL tools project to serialise the CodeModel into an XML representation of source code. It works well, and gets around a few problems with my old approach of disassembling: I don't need a project to be built, and I don't need debug information (pdbs). Unfortunately I don't get all the info I need from CodeModel, so I'm still using disassembly to read method bodies out of PE files and turn them into XML. |
|
|
What a week! |
2005-04-15 |
|
|
|
Interpol |
2005-04-10 |
|
I saw Interpol at the Brixton Academy last night. They were great. Last time I saw them it was Christmas day on some MTV music awards, when I was nearly dead from the flu in Sicily, so this was much better. |
|
|
ESEC / FSE 2005 |
2005-04-04 |
|
I just submitted a paper for the fifth joint meeting of the European Software Engineering Conference and ACM SIGSOFT Symposium on the Foundations of Software Engineering. I'll post the whole thing on line at some stage over the next few days, but the abstract sums it up pretty well: This paper discusses a tool for separating concerns within software systems. Separation of concerns helps programmers understand and alter particular aspects of a system effectively. We have developed a tool that allows programmers to represent a concern using a simple visual language, and then annotate this representation to relate parts of the concern to development artifacts like source code and documents. Programmers can then use the concern representation to interactively navigate to the relevant program artifacts. This tool takes a novel approach to the separation of concerns problem by providing several different languages for identifying relevant artifacts, as well as providing a framework for adding more languages. This allows the tool to flexibly deal with high level and low level concerns spread across many types of artifacts, and include concern definitions within other concerns to enable representations at various levels of abstraction. |
|
|
Rob Caron's Blog |
2005-04-01 |
|
Rob Caron has linked to my recent Software factories post in his TeamSystem rollup. |
|