Lenses are used in functional programming, and you’re probably using them without noticing!

Two black camera lenses on giraffe painting photo.

Definition

As per the metaphor, a lens allows us to focus on a specific part (U) of a larger object (V):

Use case, please!

Lenses are especially useful when updating a subpart of an object in a context of immutability.

In the following example, we’re willing to update only the speed of a…

From basics to more complex things to have Alice finally talk to Bob!

Black, old phone device.

TL;DR

  • Props for parent->child communication
  • Callback props for child->parent communication
  • Common ancestor: does not scale, almost an anti-pattern
  • Event bubbling: implicit coupling, clearly an anti-pattern
  • Via the server: why not after all?
  • React Context, what else?
  • Building on React Context, let’s add some contracts
  • PubSub

React is now a mature environment…

Photo of a turtle by Nick Abrams on Unsplash

Je nourrissais de longue date l’envie de créer un produit. Quelques tentatives infructueuses mais riches d’enseignements, puis, voici un an, une piste prometteuse avec un logiciel facilitant le quotidien des entraîneurs de course à pied et triathlon. Deux premiers utilisateurs enthousiastes, l’impression d’apporter de la valeur et dès lors une…

En entreprise comme dans la vie, une stratégie qui permet d’avancer à un instant donné peut se révéler contre-productive à un stade développemental ultérieur. Il faut donc se renouveler en permanence. Cette évidence est particulièrement vraie s’agissant de start-up qui entrent en phase de scale-up. Les entreprises sont nombreuses qui…

Today, as we revisit the famous FizzBuzz kata, we’ll see how to take advantage of functors for function composition.

This article is part of a series of articles to come about functional programming concepts demonstrated on well-known kata in TypeScript. No theory, just practice!

Functional programming, by enforcing immutability and favouring function composition, is a powerful yet simple way of reducing the programmer’s cognitive load, easing testability and reducing…

Mathieu Eveillard

Consultant, formateur & coach technique. https://mathieueveillard.github.io/

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store