Speaking of the Class Designer

As I pointed out in my last post, VS2005 includes a Class Designer that those familiar with the UML class model should feel right at home in. By happy coincidence, I found out today the Class Designer team is blogging. Additionally, two of the Class Designer team members – Ramesh and Rakesh - are blogging on their own. Apparently, the team blog will feature a new post every Thursday. This week’s post features an overview of the v1 Class Designer goals. Subscribed.

Putting a Square Peg Model in a Round Hole Tool

Robert Bauman left the following comment on my Separated at Birth post?

The nice thing about using a general purpose modeler is that you can house all of your requirements, use cases, etc. in the same model. Rational provides the 4+1 view, Sparx Systems Enterprise Architect provides several views out of the box that you can easily navigate around… It means that everyone is working off of the same set of rules.

As soon as you start putting those rules into Visual Studio, they change and deviate from the model. It’s true that the AndroMDA does require you to remember to use certain stereotypes, but that’s all part of the game anyhow.

That’s like saying, “well, the GoF patterns are nice, but then you have to remember what it means to have an Observer pattern”. Furthermore, UML tools let you customize the list of stereotypes that show in the dropdown, and even the picture that should be associated with those stereotypes. Why mess with some other modeling standard when you can do it all with a proper UML tool

The point I was making is that when you start using the class model to design something other than classes, you’re using a domain specific language – even if you’re using a general purpose modeling tool.  Take a look at this example from the AndroMDA website. Their example reads:

You tag a CustomerService class with a <<Service>> stereotype. AndroMDA sees this stereotype, looks into its internal dictionary of available code generation components (called “cartridges”) and finds the EJB cartridge. In the EJB cartridge, two templates correspond to the <<Service>> stereotype: SessionBean.vsl and SessionBeanImpl.vsl. AndroMDA uses the internal representation of CustomerService loaded from the model, calls the processing engine twice, and two output files are generated: CustomerServiceBean.java and CustomerServiceBeanImpl.java.

In this example, classes with the <<Service>> stereotype actually generate two code classes – the Bean and the BeanImpl. But if we were using the class diagram as it was intended, wouldn’t there be a one-to-one mapping between a class in the model and a class in the code? As soon as you break that one-to-one mapping, you’re no longer modeling classes. A <<Service>> is something at a higher level of abstraction than a class – otherwise it wouldn’t take two classes to implement it.

BTW, I’m not saying that there is anything wrong with this approach at all! I’m just pointing out the similarities between an approach that many people are using to achieve practical results with UML today and what you can do with the modeling tools that Microsoft is building.

The key difference comes down to tools. Yes, you can use the class diagram and stereotypes to model stuff at a higher level of abstraction like Services and Entities. But putting a square peg in a round hole like that has problems. Since you’re not using the tools as they were designed, you have to manually enforce rules that the tool doesn’t know about. Sure, you can add some semantics via stereotypes, but you can’t take anything away. How easy is it to build a valid class model that isn’t a valid service model? Pretty easy. For example, do services support inheritance? Classes do. My EJB is a little rusty, but I don’t think beans do. It certainly doesn’t make sense for a service to inherit from an entity or vis-versa. Yet, the class modeler will happily let you do this, even though it makes no sense in the domain you’re actually trying to model.

The value of domain specific languages is that have a tool that is specifically designed to model the domain you’re working in. If you’re designing classes, of course you’d want to use a class model. We have a great one coming in VS2005. But if you’re designing services or entities or page flows or whatever else, why wouldn’t you want a tool that’s specific to the problem at hand?

Slight Issue

I’ve discovered one thing about my Nomad/Napster To Go/WMP combo that I don’t like. Napster is wholy inconsistent when it comes to tagging their music. For example, I downloaded Denis Leary’s Merry F’n Christmas album, but half the songs are tagged that they come from the Merry F#%$in’ Christmas album. This specific example only appears to be an issue in WMP, but I also had issues with the tagging of Chris Rock’s Never Scared album. One song shows up as part of the “Never Scared” album, but the rest show up as “Never Scared [Bonus DVD]“.

I think WMP adds to the difficulty here because of the sheer amount of metadata it tracks. Artist and Album Artist for example. Good idea, but it’s really easy for those to get out of sync (check out this website for more info on that). And because these files are all DRM protected, you can’t edit the metadata in the file itself, only in WMP’s library. But I can’t figure out how the metadata & file structure on my computer corrisponds to metadata structure on the Nomad with 100% certanty.

However, even with that, I still recommend Napster to Go highly. This is a very minor issue that I think highlights a few of the remaining rough edges in a consumer scenario that involved Microsoft, Napster and the media player manufacturer. Plus, I’m anal about things like album names.

(One other side note – deleteing and rebuilding your WMP library causes all the songs on the device to be retransfered. Woops. Had to reformat the device, but since there’s nothing on it but my Napster music, it was no big deal.)

MDA And Software Factories – Separated At Birth?

Tonight I went to the monthly meeting of the local chapter of IASA. I should have also blogged this before the meeting, but I forgot. Sorry about that if you live near the Microsoft campus and wanted to go. Next meeting is on 3/30, so mark your calendars.

Anyway, tonight’s topic was an MDA workshop featuring AndroMDA. AndroMDA is an open source tool for generating primarily J2EE code for *nix boxes using UML and MDA. (To be fair, the speaker – local chapter president Chris Sterling – demonstrated generating C# code as well. Of course, he ran it under Mono on a Linux box.) This provided a great launching point for a general modeling discussion that helped me get a few things straight in my head. Typically, the UML vs. DSL discussion turns religious pretty quickly. However, I believe that people – like those a the meeting tonight – who are achieving practical success with MDA in the real world are doing so by using a Software Factories style approach.

First off, if you look at how most people use UML for MDA, the class diagram appears to be the most dominant model used. When I say “UML for MDA”, what I mean is people using UML as a blueprint or as a programming language. While UML has 12 different model types, class diagrams make up the bulk of the modeling effort. (The bulk of AndroMDA code generation works off the UML class diagram, though the BPM4Struts cartridge uses Use Case & State models as well) The other 11 diagrams are primarily used for sketching purposes. That means you’re only blueprinting the structural aspect of your system – which in turn means that all the system’s behavior has to be implemented by hand. Now, this is not to say that factories suggests you should only model the structural aspect of your system. However, I think this indicates that most pragmatic users have realized MDA doesn’t live up to the hype.

Secondly, the class diagram that are used have to be heavily adorned with custom metadata – typically in the form of stereotypes – in order to be useful for code generation (i.e. blueprint) purposes. AndroMDA has a set of “cartridges” (essentially, target code generators) such as EJB, Hibernate and POJOs. Each of these cartridges has a supported set of stereotypes. While there is some overlap (for example, EJB and Hibernate cartridges both define the Entity stereotype). These stereotypes assign brand new semantics to the elements being modeled. In short, they turn the the generic class modeler into a domain specific modeler!

It appears to me that the pragmatic MDA crowd is using the class diagram as a generic “ball and stick” editor. Model elements that aren’t needed are ignored and elements that are needed are added via stereotypes. For example, you can use a class diagram to model a database. Certain elements of the model are ignored (Can a column have protected visibility? Can one table inherit from another?) while other elements specific to the domain being modeled are added (primary and foreign keys, indexes, etc). The problem with this approach is that all of the knowledge of how to build a valid model is in the user’s head, rather than the tool. Typically, that means a lot of training as well as a lot of in depth understanding of the framework underlying the model in order to capture the right amount of information. Since all that domain specific information is trapped in the users head, they have to do a ton of menial drudge work. It’s different drudge work from things like writing tons of data access code, but it’s drudgery nonetheless.

If you’re going to need a tool specifically designed for your problem domain, why use a generic tool and a bunch of handwritten rules, when you can codify those rules into a domain specific language of your own? (I mean, other than the obvious “because the DSL Toolkit hasn’t shipped yet”)

Experimenting with Podcasting

So I’m playing around with podcasting. The new version of dasBlog supports RSS enclosures for local binaries and I’m thinking of adding support for remote binaries. (I’m not sure my friend who hosts this blog for me would appreciate the bandwidth spike from adding downloads of media files. Of course, that assumes people would listen). So far, I’m just listening. My friend Mike does his Manic Minute and I guess Daily Source Code is the defacto standard podcast. This will be easier when I get my new AUX input installed in my car.

Listening to 30 minute podcasts like DSC on my Nomad have me longing for WMP’s variable speed feature. I listen to podcasts primarily on my Nomad – the combination of WMP 10 AutoSync, Doppler Radio and Sean’s podcast playlists makes syncing down to my player effortless. But listening to Adam Curry ramble on about podcast commercialization for 45 minutes doesn’t fit into my communte. However, listening to Adam Curry sped up 1.4x would make a 45 minute show end in just over 30 minutes. But alas, the Nomad doesn’t have that feature. Does any player support that? Or does it take more proccessing power than these things are carrying around?

Note to MSTV Foundation team – variable speed support would also be a great feature for the DVR. I wouldn’t watch 24 sped up, but I might watch the Daily Show that way.

Update: I neglected to “give props” to my boss Norman for convincing me to look at this whole podcasting thing in the first place. Given how little spare time I have these days, I’m not sure that I needed yet another hobby. On the other hand, not following your boss’s suggestions or giving him props is never good for the career! 😄