3 ms·
Assessing Abstractions
- kalyantm 6y agoEver since I switched to a functional style of writing production code, I immediately see my abstractions are a lot better. I've had many instances before where I used to do function do_something(param1, param2, booleanParam1, booleanParam2) and in turn have spaghetti code based on those booleans. Composibility blew that out of the park for me personally.
- throwaway_pdp09 6y agoI've seen this complaint that using bools directly causes problems (I agree) but the solution is trivial, either turn those booleans into type-safe distinct values: flushability {FlushData, DontFlushData}; CloseFile(file f, flushability AndFlushToDisk); or roll the boolean flag into the function name: CloseFile(file f, bool AndFlushToDisk); becomes: CloseFile(file f, bool AndFlushToDisk); // the original, occasionally still needed... // ...but add, and recommend instead CloseFileAndFlush(file f); CloseFile(file f); // does not flush; name does not claim it does Why is this so difficult?