liveBook · Manning

Late binding

As explained in Data-Oriented Programming: Reduce software complexity

Late binding is the practice of deferring the determination or handling of concrete data types until runtime or a later processing stage.

Late binding defers decisions about concrete data types until they are actually needed. A database result can travel through generic collections without every step knowing whether a value is a string, integer, or another type. section 10.1

A practical question is: where must the type finally matter? In a book search, values can pass through lists of maps unchanged; the JSON serialization library handles concrete representation at the boundary. section 10.1

Database results as data

A JDBC result set becomes a list of hash maps by reading each column label and storing each value as Object. Search results can then be validated against a JSON schema and serialized as JSON. The design avoids casting during intermediate data manipulation, while preserving validation where the result crosses an external boundary.

Late binding makes data-oriented manipulation flexible:

  • Represent database rows as generic collections rather than instances of entity classes. section 10.5
  • Treat field names as strings, allowing generic functions to rename keys, group rows, or access values. section 10.5
Lodash functions introduced in this chapter

Function

Description

at(map, [paths])

Creates an array of values corresponding to paths of map

omit(map, [paths])

Creates a map composed of the fields of map not in paths

nth(arr, n)

Gets the element at index n in arr

groupBy(coll, f)

Creates a map composed of keys generated from the results of running each element of coll through f. The corresponding value for each key is an array of elements responsible for generating the key.

Generic collection functions show how late-bound maps support reusable operations across different data entities. section 10.5

How Data-Oriented Programming: Reduce software complexity covers it

How deep it goes
Defines the principle and demonstrates JDBC-to-map conversion, stopping short of detailed runtime type internals.
Examples
Demonstrates book-search rows, JDBC result conversion, map-based results, schema validation, and JSON serialization.
What it assumes
Assumes familiarity with database results and maps while introducing deferred types, field-name access, and boundary validation.
What you can do after
Apply it via generic maps and functions, then validate and serialize concrete data at system boundaries.
How it connects
Connects data-oriented programming with hash maps, generic functions, JDBC, JSON serialization, and JSON Schema.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Data-Oriented Programming: Reduce software complexity. The section links point to the parts of the book it draws on.