When is the glue too thick?

The term “glue code” is a colloquial term for “a thin layer of software that connects software”.  In general, it is used to connect to software components that were not designed to interact with each other.   This is a common problem and, when sensibly done, is a fine approach.  However, it is possible to develop “super glue” solutions which are, in the end, fragile and difficult to maintain.

“Standard glue”

TheImage result for standard glue following are examples of standard “glue code” functions.   Correctly implemented they are a thin layer between modules

  • Data format translations: repackaging data between two different formats, such as an XML to CSV translation function.
  • Communication port: adding a data transmission function between two pieces of code.
  • Registry/read functions: these are functions that map data from one source (such as requirements) onto an object (such as a model)
  • Error catching: these functions, generally, work in concert with other glue code ensuring that the data exchanged between the modules is correctly formatted.

Crazy glue

How Image result for crazy glue helmetdo I tell if I have crazy glue?  There are 4 basic warning signs

  1. Use of multiple languages:  connecting two software components written in different languages is a common task.  However, if you find your glue code uses more than one language chances are you doing something to convoluted.
  2. Use of files for the interface: ideally glue code is written by leveraging existing APIs in the software components.  If the function interface is through a file and a “poling function” the data exchange will be difficult to maintain.
  3. The growth of “special cases”:  when the number of special cases the glue code has to handle gets above 10 to 15 chances are the data exchange format is not well defined.
  4. Size: there is no hard and fast rule for how large glue code can be, however at some point in time it stops being glue and becomes its own software component.

What to do with crazy glue?

In the ideal world, the glue code would be replaced with improved APIs in the source software components.  Often this is not possible due to ownership issues.  When this is the case basic software best practice come into play

  1. Break the glue into components
  2. Look for ways for one component to encapsulate the other
  3. Refactor the code to remove special cases
  4. Consider using different software components

Image result for duct tape

 

 

 

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 )

Google+ photo

You are commenting using your Google+ 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 )

Connecting to %s