in source code » Available in some languages for « composite » types Array, associative structure (map, vector, object, etc.) Available in every languages for « scalar » types Integer, Float, Boolean, String, Character
1st recipient of the Turing Award For other « Perlism »: http://www.cs.yale.edu/quotes.html « It is better to have 100 functions operate on 1 data structure than 10 functions on 10 data structures »
simple, a Tree Literal with an array of arrays tree-seq function in Clojure structure that tree and allows “walking” it with clojure.walk Viz done with github.com/ztellman/rhizome
identity Ex : The bank account n° 30003 02367 000593287642 13, The credit card 8644 7023 0531 105 The EventBrite ticket for SoftShake Domain-Driven Design Immutable object that represents a concept whose equality is based on all the attributes and has no identity Ex : The 42 EUR amount The UUID f4fbe22a-9d53-4359- adbb-57f7d21ed549 The instant 21 october 2015 at 16:29 The distance 53 meters Value Object Entity
past participle that has a static and stable meaning (order paid, user connected, etc.) State influence the object behavior State implies that some Data Transformations occured during a state transition, triggered by an event State is associated with an identity, then together they form an entity, that represents the different states and transitions along the time A state is the relation between an entity and the values that she owns at the t instant; That state can change
State 3 Function Function Event triggers Event triggers • value 1a • value 1b • value 1c • value 1a • value 1b • value 1c • value 2a • value 2b • value 1a • value 1b • value 1c • value 2a • value 2b • value 3a Publish Internal Event Publish Internal Event ... Time
Checkout Paid Shipped pay ship Payment details from Payment Gateway received Carrier data q Customer Data q Product Lines (product + qty) q Shipping Data States checkout q Customer Data q Product Lines (product + qty) q Shipping Data q Payment Data q Customer Data q Product Lines (product + qty) q Shipping Data q Payment Data q Carrier Data Front website form submitted Order submitted event Order paid event Order shipped event Time
d’états d’une Entity Identity State 1 State 2 State 3 Function Function • value 1a • value 1b • value 1c • value 1a • value 1b • value 1c • value 2a • value 2b • value 1a • value 1b • value 1c • value 2a • value 2b • value 3a ... Time States
the entity state at a particular instant can be displayed with a data literal A diff allows to visualize the differences between the prevState and the nextState provided by the function function(input): output! function(prevState, event): nextState!
be expressed in a tabular form following the Gherkin grammar Some framework allows to input a Data Literal directly: cf framework BDD Spexec See speakerdeck.com/jgrodziski/anatomy-of-a-bdd-execution-library-in-clojure
arguments whatever the number of invocation (idempotence) Lead to no observable side effect (safe) Referential Transparency: Time doesn’t affect the result of a function, hence the function is transparent regarding time Allows « memoization », composition increase the testability
and returning new values The initial data structure is never modified Clojure provides an efficient implementation with Structural Sharing of Persistent Data Structures (values are shared between the old and new version of the structure)
and Idempotent) • Data Transformations • Data structure shape (ex : map -> list) • Values (transcoding) • Creation of new data (ex: from computation) • Decision : authorisation, result Non-pure Functions Impures with side effects (Non Safe or Non Idempotent) • Safe, Non Idempotent : Data enrichment from a « mutable » external data source (ex : read from a database) • Non Safe, Non Idempotent : Persistence (insert, update), Messaging
To Internal Enrich from external DataSource Validate Transform Transform Transform Operate (Persistence, Messaging) Pures Functions Get Data Non-pures Functions Non-pures Functions The non-pures functions are pushed to both ends of the pipeline
data structure of type List of the form: (verb a b)! Clojure is itself a Data Literal ! Allows very powerful meta-programming « Code is Data, Data is Code » from homo - the same - and icon - representation -
all the state transitions of an application like a series of events Replay is almost built-in … but is strongly dependant on the source code version that process the event at a particular momentnt t Can we store the source code which process an event besides the even itself?
10 frames as shown above. In each frame the player has two opportunities to knock down 10 pins. The score for the frame is the total number of pins knocked down, plus bonuses for strikes and spares. A spare is when the player knocks down all 10 pins in two tries. The bonus for that frame is the number of pins knocked down by the next roll. ‘/’ denote a spare in the score sheet. A strike is when the player knocks down all 10 pins on his first try. The bonus for that frame is the value of the next two balls rolled. ‘X’ denote a striker in the score sheet. In the tenth frame a player who rolls a spare or strike is allowed to roll the extra balls to complete the frame (so 3 balls can be rolled in tenth frame).