Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
Daniel Craig edited this pageApr 5, 2021 ·2 revisions

Concretion

Definition

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

Example

Dependency Inversion Principle: Entities must depend onabstractions, not onconcretions.

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 anabstract interface implemented by that class.

A more abstract way to handle dependency between entities is to invoke code bysending 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 idiomjust use maps is an application of the Dependency Inversion Principle todata. Representing data with a data class or a data record is aconcretion: 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).

CodeData
ConcreteConcrete classConcrete record
Less concreteAbstract classAbstract class with getters
Most abstractMessage passingGeneric map

See also

Abstraction

Clone this wiki locally

[8]ページ先頭

©2009-2025 Movatter.jp