Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Related Rants
It often feels like the logic and the equivalent final application code have nothing to do with each other.
Logic: Find the only element in this list that matches criterion, or the first element in this other list, or none. If the first list has multiple matches, fail.
Application: Produce information about the criterion checks for all elements in both lists for info logging. Find any elements in first list that match. Save the number of matches for an optimization that relies on a lot of assumptions about the search criterion that are only ever expressed in doc text. If one, return, if multiple, fail. Otherwise find first match in second list, produce debug hint on why the preceding elements in that list didn't match by aggregating the criterion check info. If multiple matched in second list, check highly specific interdependency, and if absent, produce warning about ambiguity. Return first match if any.
The first can be beautifully expressed as a 5 line iterator transform. The second takes 3 mutable arguments (cache, logger, criterion because it also may cache and log), must compute everything eagerly and has constraints that are neither strictly necessary for a correct implementation nor expressible in the type system.
rant
application logic
architecture