FP, OOP

Object-oriented Design Patterns From a Functional Perspective

In this post I interpret design patterns and principles commonplace in object-oriented programming languages from the perspective of functional programming. Most of these patterns are trivially reduced to elementary functional constructs. The intent is to illustrate advantages and insight resulting from a shift in paradigm. After all, both the object-oriented and the functional paradigm have a shared goal - the solution of some problem. The patterns discussed herein are a testament to this commonality. The difference between the paradigms lies in the underlying abstractions upon which they are established which in turn have significant ramifications for the problem solving tactics they engender. In particular, I argue that the object-oriented inheritance model and the paradigm’s primary utilization as an adorned state encapsulation mechanism are limiting factors in composing higher-level abstractions. Conversely, functional programming, being based on an entirely different model of computation, eschews state, thereby bypassing accompanying hurdles and mandates composion from the core, thereby encouraging resuable abstractions.

Read on →
DDD

Sub-domains and Bounded Contexts in Domain-Driven Design (DDD)

In this post I discuss the subtle relationship between bounded contexts and sub-domains within strategic Domain-Driven Design. The concepts often seem elusively similar, yet in reality are more like parallels. To understand the parallels, the association between a domain of discourse and the corresponding model shall be investigated. My understanding of the subject matter was honed at DDD Denver Lean Coffee Discussions organized by Paul Rayner.

Read on →
DDD, F#

Domain-Driven Design (DDD) With F# - Validation

In this post I dig deeper into validation of a Domain-Driven Design with F# and the functional paradigm. The implementation builds upon the design introduced earlier. The central theme is that of explicitness - the possibility of a failure is made explicit with type signatures. In turn, this calls for explicit handling of failure conditions paving the way for a design-by-contract style of programming and equational reasoning. Under the hood, the implementation draws on basic principles of category theory which provide for uniformity and composability. As a result, from the perspective of DDD, the confluence of declarative design, supple design, invariants and assertions is tremendously enhanced. The functional implementation of validation is to a great extent based on the wonderful work of Mauricio Scheffer.

Read on →

Domain-Driven Design (DDD) With F# and EventStore - Projections

In this post I cover the introduction of simple projections into the InventoryItem domain project implemented with F# and EventStore.

Projections implement the query side of CQRS. Specifically in EventStore, projections are a mechanism for transforming event streams into other event streams. This has a wide range of applications including CEP. For this project, projections were used to generate read models, also known as views or query models.

Read on →