Glue code
This article may require copy editing for grammar, style, cohesion, tone, or spelling. (October 2014) |
In programming, Glue Code is code that serves solely to "glue together" different parts of code that would not otherwise be compatible. It does not contribute any functionality towards meeting the program's requirements, but instead Glue Code often appears in code written to let existing libraries or programs inter-operate, as in language bindings or foreign function interfaces like the Java native interface, or when mapping objects to a database using object-relational mapping, or when integrating two or more commercial off-the-shelf programs. Glue code may be written in the same language as the code it is gluing together, or in a separate glue language.
Context
Glue code usually does not serve any use in actual calculation or computation. Rather it serves as a proxy between two incompatible parts of software, making them compatible. Standard practice is to keep logic out of the glue code and leave that to the code blocks it connects.[1] While glue code can enable the transfer of information between computer languages, it is not required to do so.
It is quite common for different parts of the program to alert each other about different events or errors that have occurred.[2] This is especially useful when the different factions of a program are used in conjunction with external devices or user interfaces. Glue code is essential when trying to obtain data from other components in the system. Some glue code generators allow user-specified data to be passed between code modules. For example, a submit button on a user-interface forum must notify the application that the user has pressed submit. However, moving large pieces of data between code blocks using connecting code is not always reliable.
Glue code can be used to connect code modules of any size, from small functions to large libraries. Depending on the amount of proxy code generated for this purpose, there may be a significant amount of code bloat and overhead, so connecting small pieces of code in this way may not always be ideal. When synchronizing calls to large libraries or merging large code repositories, on the other hand, a small amount of glue code can be an invaluable way to bring functionality where it might otherwise be unavailable.
Usability
Glue code allows interconnection and integration of programs and different languages. Glue code often consists of the same languages that it is connecting. Specifically, when it connects distinct computer languages, it contains code pieces specific to each code module it is putting together.[3] For example, to connect a component using Java and a component using C#, the glue code would contain both Java and C# in that file. So long as the factions that the code is connecting don't change, the glue code doesn't need to change; although it may need to be updated. Generated files are rarely changed by a developer. The end-user should never have access or be able to change the glue code.
Glue code can connect code modules of any size. Depending on the amount of proxy code generated, it can glue together small functions to large libraries. Because of code bloating and overhead, glue code is best used on larger files. On the other hand, merging large libraries can make it inefficient for a small amount of glue code to bring functionality.
Glue code is very efficient in rapid prototyping environments where several components are quickly put together into a single language or framework.
See also
References
- ^ http://www.wisegeek.com/what-is-a-glue-code.htm.
{{cite web}}
: Missing or empty|title=
(help) - ^ http://www.techopedia.com/definition/19608/glue-language.
{{cite web}}
: Missing or empty|title=
(help) - ^ http://www.wisegeek.com/what-is-a-glue-code.htm.
{{cite web}}
: Missing or empty|title=
(help)
- ^ http://www.site.uottawa.ca:4321/oose/index.html#gluecode University of Ottawa: Object Oriented Software Engineering, Glue Code Def.
- ^ http://projects.camlcity.org/projects/dl/findlib-1.2.1/doc/guide-html/x341.html
- ^ http://www.techopedia.com/definition/19608/glue-language
- ^ http://www.wisegeek.com/what-is-a-glue-code.htm
- ^ http://www.doc.ic.ac.uk/~np2/patterns/scripting/glue-code.html
- ^ http://projects.camlcity.org/projects/dl/findlib-1.3.0/doc/guide-html/x341.html