On 'leaky abstractions'
Recently I was reviewing a pull request, and a rather simple piece of code got my attention as a good example of 'leaky abstractions'. So, let's review it. I removed all specific implementation details and made the sample code very generic while maintaining the 'leaking pattern'. public record Data(int Id, long Value, bool Flag); public IEnumerable<Data> CallingMethodWithLeakingAbstractions() { var input = ProduceInput(); var result = LeakingProcessing(input); result.AddRange(input.Where(x => !x.Flag)); // probably do some other things unrelated to modifying the result return result; } private List<Data> LeakingProcessing(IList<Data> source) { return source .Where(x => x.Flag) .Select(ProcessValue) .ToList(); } private Data ProcessValue(Data input) { ... }; We have a Data record (class) and some processing for it. So, why do I think this sample demonstrates the 'leaky