Powerful Aspects

Aspects are not really a new concept though their popularity and utility have come to the fore with the recent availability of support in programming languages, tools, and frameworks. Aspects enable us to separate various (cross-cutting) concerns from the core ones. This a good design goal though a poor application of aspects can also undo any desired benefits. There are numerous useful resources related to this topic which can be located by searching for aspect or aspect-oriented programming (AOP). Here I want to share what aspects can do for a content management system like Alfresco.

A content item (typically a document) consists of two pieces of information – the content (file) and metadata (properties/attributes) that contains information about the document. For example, common metadata for a document includes title, subject, and authors. The properties included in the metadata are specified by a content type. In terms of object-oriented design, the content type is not much different from a class.

Similarly, content types often support an inheritance-hierarchy for defining new content types based on existing content types. There are two well-known issues along with the benefits of such a type-inheritance hierarchy:

  1. Single inheritance (one type can only have one parent type) limits the reuse of multiple existing types in a new type. Multiple inheritance has its own problems and is generally fallen out of favor.
  2. A document of a particular type can only have the properties mandated by the type.

Consider this simple example. Suppose there are certain documents that need to be published in some sense and require an effective date range in terms of an effective_date and an expiration_date. Further, these documents may be of arbitrary content types – the only constraint is that if they need to be published they should have these attributes. If we are using the type inheritance-hierarchy these two properties need to be present in common base type(s) for all possible document types that may have this need to be published. As a by-product these two properties will be present on all the documents of these types, no matter whether they are published or not.

The key issue here is separation of concerns. The effective date range is required for certain documents (irrespective of their types) depending upon their intended usage. Essentially, if a document needs to be published in some way and should be available only during the effective date range then those documents should have these two properties.

Aspects serve this purpose beautifully. An aspect can be thought of as a pseudo-object that can be slapped on to another object – effectively resulting in additional properties on selected objects. Aspects are not bound by the content type of the object. In Alfresco, the problem described above is solved with the built-in aspect called Effectivity. Just add Effectivity on specific documents or specify a rule on a space (folder) to apply this aspect to all the documents added (possibly recursively) to a space.

How does Documentum handle this challenge? In the current version (5.3), a_effective_date and a_expiration_date are properties on dm_sysobject type, which is a base type of several other types. As a result, these properties are present on a lot of objects even though they might not need them. Also the Object Reference Guide groups various attributes under labels such as X-related, Y-related, etc. some of which are not related to the core concerns and may be better served by aspects. However, the next major version (D6) plans to add support for aspects. Although this will facilitate management of new aspects, I am wondering if there are plans to refactor the existing organization of types. The dilemma is between leaving the bloat in place or to create a lot of change (due to reorganization with upgrade) with potential regression effects.

Documentum is hardly to be blamed in this regard since Alfresco, being a relative newcomer in the space, probably had the advantage of hindsight. On the other hand, one downside of being a newcomer is that Alfresco had to start with a 0% market share.

My concluding thought is one of caution. It is easy to make a golden hammer out of aspects. Suddenly, there is a choice between putting attributes on a content type or on an aspect. Usage of aspects will also carry some overhead of its own. Indiscriminate adoption of aspects may even lead to a maintenance nightmare. So measure twice and cut once – reap the best of strong typing as well as of aspects.

Advertisements

4 thoughts on “Powerful Aspects

  1. Hi,

    Did you tried deploying the Aspect using DAB 5.3 sp5. I want to understand the deployement strategy of aspects using docapps.

    Thanks
    Prakash

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s