Skip to content
Daniel Craig edited this page Apr 5, 2021 · 2 revisions

Concretion

Definition

Concretion is when in order to use something we need a concrete knowledge about the thing.

Example

Dependency Inversion Principle: Entities must depend on abstractions, not on concretions.

The common way to apply DIP to Object-Oriented programming is that when a class depends on another class, it should not depend on concrete instances of the other class. Rather, it should depend on an abstract interface implemented by that class.

A more abstract way to handle dependency between entities is to invoke code by sending a message to an object. The only required knowledge is the name of the message, represented with a generic entity (e.g. a string).

In Clojure

In a sense, the Clojure idiom just use maps is an application of the Dependency Inversion Principle to data. Representing data with a data class or a data record is a concretion: The only way to access data is via the class methods or record members.

When we access data through the methods of an interface, it's a bit less concrete. But still, we can access data only through the methods defined in the interface.

A more abstract (less concrete) way to represent data is with generic maps. In order to access data in a map, the only required knowledge is the field name, represented with generic entities like strings (or Clojure keywords).

Code Data
Concrete Concrete class Concrete record
Less concrete Abstract class Abstract class with getters
Most abstract Message passing Generic map

See also

Abstraction

Clone this wiki locally