Compose

What is composition ?

Action ou manière de former un tout en assemblant plusieurs éléments

What is not composition  or micro composition

For Filter

var numbers = [1, 2, 3, 4];

var evenNumbers = new List<int>();

for (int i = 0; i < numbers.Count; i++)
{
  if (numbers[i] % 2 == 0)
  {
  	evenNumbers.Add(numbers[i]);
  }
}

Composable Filter

[ 1, 2, 3, 4 ].Where(n => n % 2 == 0);

Less Code

Less cognitive load 

and...

Highly Composable 

[ 1, 2, 3, 4 ]
.Where(n => n % 2 == 0)
.Select(n => 2 * n)
.Sum()

Spot pattern

List<int> numbers = new List<int> { 1, 2, 3, 4, 5 };
List<int> squared = new List<int>();
for (int i = 0; i < numbers.Count; i++)
{
    squared.Add(numbers[i] * numbers[i]);
}
Made with Slides.com