liveBook · Manning

Glue code

As explained in Get Programming with JavaScript Next: New features of ECMAScript 2015, 2016, and beyond

Code whose main purpose is to connect separate modules or components together.

Glue code is the application logic that connects separate modules. When each module has a focused role, the code tying them together can stay simple. section 26.3 section 22.1

A game’s integration layer

In Blackjack, the main file imports card, utility, and DOM functions, creates the deck and hands, renders them, and wires player actions to game logic. A Hangman plan similarly places the code connecting its game and UI modules in index. section 26.3 section 22.1

Listing 26.12. src/index.js
import { cardTemplate } from './templates'; import { wait } from './utils'; import { dealerEl, playerEl, buttonsEl, updateLabel, status, render, addCard } from './elements'; import { createDeck, pop, countHand, dealInitialHand, flipCardDown, flipCardUp } from './cards';

The imports show the range of modules the Blackjack integration code brings together. section 26.3

How Get Programming with JavaScript Next: New features of ECMAScript 2015, 2016, and beyond covers it

How deep it goes
Shows integration from imports and setup through rendering, game turns, and event listeners.
Examples
Uses Blackjack setup and play, plus a Hangman plan that places integration code in index.
What it assumes
Assumes focused modules already exist and does not show building them from zero.
What you can do after
Build it from scratch by importing modules and wiring their functions into game behavior.
How it connects
Links application logic with utility, card, status, and user-interface modules.

Also explained in

Compare how 2 books explain glue code →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Get Programming with JavaScript Next: New features of ECMAScript 2015, 2016, and beyond. The section links point to the parts of the book it draws on.