The Real Inversion of Control

A recent conversation with my friend and colleague Erik Meijer provided the nudge to finally write about something has been bothering me for some time. So here it goes…The popular view about Inversion of Control (IOC) is that it represents a technique for removing dependencies in object-oriented programs. People immediately think of their favorite dependency injection framework, whatever that may be. That’s nice and well, but is that the real IOC?Consider the following:

  • XML was pitched as a language specifically designed to make parsing easy so developers would not have to write another parser. That has happened allright, very few worry about parsing XML today. However while computers spend less cycles parsing well-formed markup, people crippled their languages with angle brackets, end tags, and a verbose syntax. This in spite the fact that the number of language users > number of XML parsers.
  • Good SOA design recommends building stateless services. Service implementations that follow these guidelines retain nothing from one invocation to another. However while the services do almost nothing to maintain the state of the service conversation, the developers building service consumers picked up the tab. Again, the number of service consumers > the number of services.
  • Web browsers allow people to interact with applications through widgets such as text boxes, radio buttons, check boxes, buttons, and a few more. These widgets are so primitive that they easily map into the native widgets provided by the virtually all contemporary host environments. However while the browser happily renders widgets with consipcuous text UI era traits, developers jumped through many hoops to push the user experience closer to what the platforms have been providing for years. And you guessed it, the number of web applications > the number of browsers.

There are other examples but I’ll stop at 3. The commonality across them is that in each case the software is simpler somewhere because many developers picked up the tab somewhere else. Instead of localizing complexity and putting the machines to work so we could enjoy other, more interesting challenges, the opposite happened. We now have to write in a verbose, ugly-looking language that the software can easily process; manage the state of service conversations so the servers would not bother about it; use plugins and pull lots of strings to give the user experience a face lift so the browsers do minimal processing and rendering; and so on. So consider this other way to look at IOC: the software is in control, and we’re working for it. Darn did I take the blue pill?

Posted in work | Leave a comment

Architecture Evaluation in Practice

The slides from my talk on employing state of the art methods to validate software architectures are available (I just didn’t get to it earlier). I gave this talk at the 10th JAOO in Denmark, and then at the patterns & practices summit in Redmond, WA. Though I distilled the talk from experience with ATAM and SAAM, you may find the recommendations useful even if you’re employing other methods. If you’re not familiar with SAAM and ATAM they’re described in the SEI book.

Posted in Uncategorized | Leave a comment

Correlation and Causality

As we wrapped up a group discussion I was reminded about the wonderful discussion of correlation and causality from Freakonomics. How do they differ? When is it one, and when is it the other? Why do people confuse them? The book illustrates eloquently the differences between them. And any mention of causality needs the obligatory reference to the Merovingian: You see there is only one constant. One universal. It is the only real truth. Causality. Action, reaction. Cause and effect.

Posted in Uncategorized | Leave a comment

The Blog-Tag Game

Wojtek blog-tagged me so let’s continue this 21st century pyramid scheme. Here are 5 things you’re not likely to know about me:

  • I have 8 years of classical piano training; I haven’t played the piano in a very long time though.
  • When I was young and foolish I’ve done a bit of rock-climbing.
  • The first framework I’ve ever extended was Digital Research’s CP/M; it came with the source code for the BDOS and a skeleton for the BIOS that provided the 8080 interrupt-driven entry points.
  • My musical preferences span an unusually wide range. For example classical, ethnic, electronic, progressive rock and rock.
  • I like all wheel drive station wagons and dislike motorcycles.

My turn: Greg Wdowiak, Steve Freeman, Paul Brown, Nat Pryce and Brian Foote.

Posted in Uncategorized | Leave a comment

Just shipped: WSSF and WCSF

Two of the projects I’ve been involved with since I started in Microsoft’s p&p group have just shipped:

Both ship in source code and include reference implementations.

If you haven’t heard of software factories my colleagues Jack Greenfield, Keith Short, Steve Cook, Stuart Kent have an excellent book with the same title.

Posted in work | Leave a comment

Software Patterns Exhibit Positive Network Effects

I’ve just wrapped up work on a patterns article. While doing the analysis with my co-authors (an co-workers) Ade Miller and Wojtek Kozaczynski I wondered about the connection between software patterns and Metcalfe’s Law.

By the way, if you’re interested in reading about how Metcalfe came up with the ideas that ultimately led to Ethernet read Michael Hiltzik’s book; you will thank me later.

Clearly the more people know about patterns, the better you can communicate with them (since instead of waving hands you would say Decorator, Broker or Service-Oriented Decomposition). Regardless of whether the growth is quadratic or not, the value of patterns increases with the number of people who use them. Stated otherwise, patterns exhibit positive network effects.

Posted in Uncategorized | Tagged | Leave a comment

Software Patterns Survey

In the patterns & practices (p&p) group at Microsoft we have been using software patterns for several years. I’m working with a couple of colleagues on gauging how the folks employing the guidance coming out of p&p (such as guides, application blocks, software factories and reference implementations) have, are, and will be using software patterns.

To do that we assembled a short survey. If you’ve used patterns I encourage you to take it. If you haven’t used patterns yet but your development tools use patterns one way or another then you could also take it since I’m also interested in your perspective.

You can find the survey Software Patterns: Past, Present, Future here. Thank you in advance for your answers.

Posted in work | Tagged | Leave a comment

A Pattern Language for Versioning

Global Context: Software Change

You are releasing a piece of software (i.e., a software artifact) for others to (re)use as a building block in their software. Reusable code fragments could be delivered as libraries, software components, applications, services, etc. Others find your artifact useful and begin using it. They could use the functions or classes within your library; they assemble applications out of your component(s); they compose your application in their workflows; they build business processes that invoke your service(s).

Once others start reusing your software you discover that you need to modify it. There are instances where modification is not possible. For example, software controlling deep sea sensors or satellite equipment may be out of reach and thus impossible to change, even when its users would like to do so. However nowadays that is the exception rather than the norm. But why change software artifacts that others are using?

One common reason for software change is a bug fix. In spite of stringent testing procedures the probability of finding errors after the software passes quality assurance and ships is not zero. Consequently you (or those using your software) may discover an error in released software. After understanding what is causing the error you modify the code to correct it.

Another driver for change is evolution. The requirements change. For example, new legislation may mandate compliance with a standard. Alternatively there could be a change in the environment. For instance, one of the systems your software is integrating with is being phased out and replaced with a new one. The new systems have slightly different interfaces and your software must change to accommodate them.

Regardless of reason changing software could cause failures—an undesired effect—even when the change fixes an existing error. Consequently the value of the change is context-dependent. For some users the change critical: they cannot operate without it. For others the cost of accommodating the change may be higher than the cost of compensating for it: their software may be counting on the bugs being there, and removing them would entail significant work.

Software change and its impact on those using the software provide the shared context for this pattern language.

Non-breaking Change

Not all types of software change cause failure, having an undesired effect on its users. Sometimes nothing breaks following a change. Ideally all changes would non-breaking. In reality this is the exception rather than the rule, which makes this case uninteresting.

Breaking Change

You released a software artifact. After the release you change it to accommodate a bug fix or a new requirement. You release a new artifact that replaces the old one. However its users start having problems; clearly the shift from the old artifact to the new one is not a NON-BREAKING CHANGE.

Why would a software change cause failure?

A change breaks software when the new artifact (i.e., the software with the change applied) violates one explicit or implicit expectations that the users of, or other software that depends on it, have about the old artifact.

Therefore:

A change that violates an expectation about a software artifact impacts its dependents. User interacting with the artifact may experience unexpected behavior. Likewise, other software using the artifact may fail to integrate. These violations have the potential to cause failure, thus making the change a BREAKING CHANGE.

The expectations could be embodied as contracts or assumptions.

The contracts subject to change when a new artifact replaces an old one could be:

  • Syntactic. For example, the number of arguments required by a method call changes from 2 to 3.
  • Semantic. For example, the amount returned by a service changes from comprising no taxes to including the sales tax.
  • Behavioral. For example, a function call changes from being side-effect free to having side-effects.
  • Quality of service (QoS). For example, a credit check service’s availability changes from 6AM-6PM to 2AM-midnight.

Assumptions can be violated. Garlan [ref] discusses the consequences of dealing with implicit assumptions in the context of composite applications.

BREAKING CHANGEs may keep the users of your software artifact from replacing the old with the new. This impacts maintainability in a negative manner and thus may not be feasible.

Substitutability Check

People use software that is subject to change. Since their correct operation depends on this software they want to assess whether a software update (i.e., replacing an old piece of software such as a library with a new one) would cause their system to break.

Can I substitute the old with the new?

Answering this question entails checking the effect of replacing the old with the new.

The easiest way is to replace the old with the new and see whether the system still works as it should. However if there are problems doing so may have irreversible consequences (e.g., life support system). Even if you can do it, what guarantees do you have that your observations cover all the possible effects of the changes? You need a means of testing for breaking changes that doesn’t impact the existing system/has low risk, and offers great accuracy (i.e., no misses).

Therefore:

Perform a substitutability check to determine whether a software artifact (library, component, service, etc.) can be replaced with a new one without causing a breaking change.

No side-effects translates into performing the check outside the live environment.

There are 2 options, analytical and empirical. High accuracy cannot be achieved in through an empirical check unless the artifact is small and simple. An analytical check requires iterating through all changes and assessing their potential impact. This is impossible without a list of what has changed (i.e., a diff), understanding the changes and their potential interactions and side effects. This is feasible only if you have visibility inside the artifact and understand how it works.

There are several dimensions to performing a SUBSTITUTABILITY CHECK.

One dimension covers who performs the check:

  • Person (manual)
    • Read the changes file and assess impact
    • Perform visual inspection
    • Try it out
    • Perform formal analysis
    • Run test suite
  • Software (automatic)
    • Manager component

Another dimension covers when is the SUBSTITUTABILITY CHECK being performed:

  • At evaluation time. You receive an update and decide whether to substitute (upgrade)
  • At build time. The IDE/compiler must pick between the old and the new library to link against
  • At run time. The runtime must pick between the old and the new dynamic library to load. As with other late binding mechanisms, going this route requires accounting for a failed check at run time.

The SUBSTITUTABILITY CHECK is a procedure that determines whether replacing an old software artifact with a new one will cause BREAKING CHANGEs. The next pattern answers the same question without requiring complex analysis.

[More coming soon so stay tuned]

Posted in drafts | Tagged | Leave a comment

Process Models for the Masses

A decade ago few people dealing with code were interested in business processes. That’s no longer the case. Due to a variety of reasons many developers discuss processes in one form or another. Some want to understand the business process that the appplication they’re building implements. Others want to grok the coordination of the services comprising their SOA. Yet others leverage workflow engines to implement the flow of pages in web applications (i.e., page flow).

A large fraction of these folks assume that processes always involve activities and their sequencing. Right? Wrong! Just because the workflow/orchetsration/coordination/etc. engine they picked to implement your process revolves around activities doesn’t mean that that’s the only way to think about a process. There are many instances when representing a process as a set of activities is unfeasible. Consider for example a web-based shoppping site: at any point you can perform one out of many activities: add something to your shopping cart; remove something from your cart; checkout; update your profile; save the cart for another visit; and so on. How would you represent somethig like this with activities?

What’s missing is the process model, something that not many newcomers are aware of. In a nutshell the process model provides the set of abstractions, relationships, and constraints that allows people to define processes. Several process models are available, each of which is suitable for a particular class of problems.

The most popular process model is activity-based. Its abstractions represent the activities performed as part of the process (or the states between these activities). This model is suitable when the process can be described through activities. It is also easy to understand because the activities resemble the elements of structural programming. However, as the web-based shopping example illustrates, sometimes it’s cumbersome to express a process as a set of activites.

Another process model uses conversations among participants as the fundamental abstraction. This model has its roots in social sciences and was pioneered by Terry Winograd (a computer scientist) and Fernando Flores (a philosopher). Together they founded Action Technologies, a company that in the mid-1980s built the first workflow system employing a conversation-based process model). Winograd and Flores describe the ideas behind their Business Interaction Model and ActionWorks in Understanding Computers and Cognition. Anyone serious about workflow ought to read their book.

A third process model uses the artifact produced as the process unfolds as its key abstraction. Though not as popular as the activity-based process model the artifact is well suited for representing processes where at any point one out of many actions are possible, such as an e-commerce Web site. The work of Richard Hull and Jianwen Su (among others) focuses on this process model. AT&T’s Vortex workflow system represents a research prototype built around the artifact-based process model.

I’m sure there are other process models, including hybrid ones that combine some of the above. Unfortunately the literature is scarce in this area. In addition, the increasing popularity of the activity-based process model (mostly because people don’t know any better) will only bury the other models even deeper.

Posted in Uncategorized | Leave a comment

Feature Extraction Revisited

A visit to pandora.com prompted me to revisit the topic of feature extraction. Tim Westergren’s Music Genome Project is probably one of the coolest ways of exploring feature extraction and relevance feedback:

  • The feature extraction part extracts the “phenotypes” from a piece of music you like and uses those features to find similar tunes.
  • The relevance feedback part uses your input (thumbs up/down) to refine the search.

So starting from “Jimmy Smith” and after a few course corrections the suggestions (e.g., Lou Donaldson’s Funky Mama) started to sound like what I was after.It’s great to see feature extraction and relevance feedback demonstrated in such an intuitive way. It’s also great to see that the Music Genome Project got it right. Others are still having problems employing these technologies right. For example, Amazon’s recommendations insist on recommending based on items that I bought but not for myself. I bet they’ll get more mileage (read sales) if their recommendation algorithms would discriminate between an item’s intended recipient and the person buying it. Are you listening?

Posted in Uncategorized | Tagged | 2 Comments