Feasible Service Reuse

Yesterday, I posted about services and reuse. More to the point, I posted why I don’t believe that business services will be reusable, any more than business objects were reusable. However, “can’t reuse business services” isn’t the whole story, because I believe in different kinds of reuse.

The kind of reuse I was writing about yesterday is typically referred to as “black box reuse”. The idea being that I can reuse the item (object or service) with little or no understanding of how it works. Thomas Beck wrote about colored boxes on his blog yesterday. Context impacts reuse – the environments in which you plan to reuse an item must be compatible with what the item expects. However, those contextual requirements aren’t written down anywhere – at least, they’re not encoded anywhere in the item’s interface. Those contextual requirements are buried in the code – the code you’re not supposed to look at because we’re striving for black box reuse. Opaque Requirements == No Possibility of Reuse.

As I wrote yesterday, David Chappell tears this type of reuse apart fairly adeptly. Money quote: “Creating services that can be reused requires predicting the future”. But black box reuse this isn’t the only kind of reuse. It’s attractive, since it’s simple. At least it would be, if it actually worked. So what kind of reuse doesn’t require predicting the future?

Refactoring.

I realize most people probably don’t consider refactoring to be reuse. But let’s take a look at the official definition from refactoring.com:

Refactoring is a disciplined technique for restructuring an existing body of code, altering its internal structure without changing its external behavior. Its heart is a series of small behavior preserving transformations. Each transformation (called a ‘refactoring’) does little, but a sequence of transformations can produce a significant restructuring. Since each refactoring is small, it’s less likely to go wrong. The system is also kept fully working after each small refactoring, reducing the chances that a system can get seriously broken during the restructuring

Two things about this definition imply reuse. First, refactoring is “restructuring an existing body of code”. It’s not rewriting that existing body of code. You may be making changes to the code – this certainly isn’t black box reuse – but you’re not scrapping the code completely and starting over. Second, refactoring is making changes to the code “without changing its external behavior”. You care about the code’s external behavior because somewhere, some other code is calling the code you’re refactoring. Some other existing piece of code that you don’t want to change – i.e. that you want to reuse.

When you refactor, you still reuse a significant amount of the code, but you’re not having to predict the future to do it. Refactoring**is the kind of reuse I believe in.

In his article, David talks about types of reuse such as business agility, adaptability and easily changeable orchestration. These look a lot more like refactoring than black box reuse to me. Unfortunately, David waves these away, saying  “Still, isn’t this just another form of reuse?”. Reconfiguration hardly qualifies as “predict the future” style reuse that he spends the rest of the article arguing against. It’s just one paragraph in an otherwise splendid article, so I’ll give him a pass this time. (I’m sure he’s relieved.)

Hard on Hardware

I guess being “Harry’s Computer” is a rough gig. Right before I went on vacation a few weeks ago, the power connector on my laptop started acting up. I’d plug it in, but it wouldn’t charge. Typically, replugging it would solve the issue. When I got back from vacation, the help desk tech took one look at it and realized I needed a new power connector. OK, how long will that take? Supposedly a day or two, but in the end it took a week and a half. It arrived Monday afternoon, right after I left for a two day SOA workshop (more on that later). To make matters worse, the power connector has now completely broken off, so I’m having to lug my docking station around if I want to charge my laptop.

Then, to make matters worse, my power cable had stopped working. Luckily, my buddy Dale is up here in Vancouver with me at this workshop, so I’ve been able to borrow his. But seriously, a broken power cable? How does that happen? I mean, it’s not cut or anything. But if you share the transformer box, you can hear something broken inside rattling. That’s not good.

So I have a busted power cable that I can’t connect to my laptop anyway because of a broken power connector. Frankly, I’m a little worried about what will go wrong with this machine next. But since it only seems to happen when I’m on the road, and I’m not scheduled to go on the road again anytime soon, I guess I’ll survive.

A Question of Context

A couple of weeks ago, David Chappell posted a great article on SOA and the Reality of Reuse. When someone mentions the idea of using SOA for reuse, I cringe. David does a great job blowing the “SOA for Reuse” argument out of the water. In the future, I will just send that link rather than spending the time arguing out the point.

But something nagged at the back of my brain about that post. David starts by talking about object reuse before making the parallel to services. The problem with that comparison is that object reuse hasn’t been a failure. When was the last time you wrote a String class? A Linked List? A Button? There’s been support for Buttons in Windows since at least the 3.x days (probably longer, but that’s before my time). Whatever your OO language of choice, there’s a big collection of reusable objects to go with it.

Given his position as “famous technology author”, I’m assuming David is well aware of successes of object reuse. Furthermore, I doubt it was an accident that in his article he writes that “reuse of business objects failed” (emphasis added). While there has been success around object reuse, essentially none of those successes have been in a business scenario. In fact, there have been some high profile projects such as Microsoft’s Business Framework and IBM’s San Francisco Project that have crashed and burned been significantly less than successful.

So here’s the question: given that general object reuse has seen some success, what’s so different about business objects that causes reuse to fail utterly? Since we’re really interested in service reuse, knowing why some object reuse succeeds and other reuse fails will help us understand which services are likely to be reusable and which wont. I would say that success of object reuse hinges on context.

Wikipedia gives this definition of context: “The context of an event, word, paradigm, change or other reality includes the circumstances and conditions which surround it.” (emphasis in original) For example, the word “order” is ambiguous. If you’re using a procurement system for the military, you could conceivably be given an order to place an order. (OK, that’s silly. But you get the idea.) The word “order” has two different meanings. However, the words that surround the ambiguous term make the meaning clear. An order that you place is different that an order that you give. That’s context.

A string or a linked list or a button has very little in the way of contextual needs. That is to say you can use it the exact same way in a wide variety of environments. A business object on the other hand has significant contextual requirements, which makes reuse difficult or impossible. For example, a Purchase Order object from the above-mentioned military procurement system sounds like it might be reusable. At least until you take into account the differences between branches of the military, between ordering tanks and ordering uniforms, between active units and reserve units, etc. Once the generic Purchase Order has been specialized to the point of practical usability for a given scenario, it’s no longer reusable in the general case.

Taking this back to the service realm, likewise I figure the reusable services will be the ones with little or no contextual needs. A good example is the identity and directory services such as Active Directory and its competitors. Sure, you use LDAP not SOAP to access it, but AD is certainly both reusable and a service plus it’s in wide usage. Other candidates for reusable services my team is looking at are service directory, management and operations, business activity monitoring and provisioning.

I actually think there will be less reuse in services than there was with objects. The value of reuse of services has to exceed not only the contextual issues but also the overhead of distributed access. Calling across the network is an expensive operation – whatever’s on the other side better be worth the drive. I’m guessing for services, more often than not, reuse won’t be worth the trip (if it’s possible at all).

Update: David pointed out to me that the last paragraph of his article begins:

Object reuse has been successful in some areas. The large class libraries in J2EE and the .NET Framework are perhaps the most important examples of this.

Doh! I guess my “assumption” that David is aware of successful object reuse was correct.

Managed Lex and Yacc

Buried deep in the docs for v3 of the Visual Studio SDK is something called the Managed Babel System. Babel – in the context of Visual Studio – is the framework for creating language services for stuff like syntax highlighting, brace matching, and IntelliSense completion. As part of the Managed version of Babel, the VS SDK includes the Managed Package Lex Scanner Generator (MPLEX) and the Managed Package Parser Generator (MPPG). Online docs are pretty thin, but there are a few white papers in the additional documentation of the VS SDK install.

Interestingly enough, the white papers were written by John Gough of QUT’s Programming Languages and Systems group. John wrote Compiling for the .NET Common Language Runtime and PLAS has several interesting language projects including Metaphor and Ruby.NET. As you might expect for a group that focuses on languages on .NET, they have a managed version of YACC called GPPG available and John said at Lang.NET that they would be releasing a managed version of LEX “soon”. I’m thinking that QUT’s GPPG/GPLEX combo has been absorbed into the VS SDK and renamed MPPG/MPLEX. Unfortunately, my laptop power connector is broken, so I can’t verify this until Monday.

It’s not a Rosetta stone and the lex/yacc model is getting pretty long in the tooth, but I’m thinking at least Larry O’Brien will be interested in these tools.

Update: Apparently, this is somewhat old news, as per Aaron Marten:

The tools we’re including are called MPPG & MPLex (which stand for Managed Package Parser Generator and Managed Package Lexer). They are derivative works from the open-source GPPG/GPLex tools developed at the Queensland University of Technology.
[Managed Language Tools in Visual Studio 2005 SDK]

Gamer Card Plugin for WL Writer

In my last post, I wanted to include a link to my gamer card, showing the NHL 07 logo on it. It turns out that in addition to the “official” gamer card from Xbox.com, there’s also the MyGamerCard.net site which provides both image and flash versions of gamer cards. Since I’m using Windows Live Writer, and I hear it’s really easy to extend, I decided to throw together a plugin for inserting Gamer Cards. It was, as advertised, extremely easy. I spent more time laying out the dialog box than I did writing the code to interface with WL Writer.

The plug in provides basically five Gamer Card options:

  • Standard Xbox.com Gamer Card
  • MGC.net Gamer Card image with link to Xbox.com Profile
  • MGC.net Gamer Card image with link to MGC.net Profile
  • MGC.net Gamer Card image only
  • MGC.net Gamer Card flash movie

I’m interested in feedback and suggestions for future versions. MyGamerCard.net provides ten different Gamer Card styles (that’s my Gamer Card to the left) so that’s an obvious enhancement for another day. I’d also like to evolve the plugin into a “Smart Content Source”, which allows you to edit the content after it’s been created (like the default “Insert Map” option). Finally, I’m thinking of adding support for GamerScoreChart.com.

Download GamerCard.WriterPlugin.Setup.zip (142.41 KB) and enjoy. Let me know what you think.