2 ms·
> And what happens when you have orthogonal traits ? You have to implement a matrix of all valid permutations ? No, you'd use polymorphism. As a silly example
by lmm 3y ago
> And what happens when you have orthogonal traits ? You have to implement a matrix of all valid permutations ?
No, you'd use polymorphism. As a silly example (but it demonstrates the technique), look at the phantom-typed builder pattern, where you can set the fields in any order you like but you can't build until you've set all of them.