The total volume of code needle produces is O(average_number_of_items_in_the_dependency_protocols x total_number_of_paths_in_the_component_tree). At Uber, the first one is slightly high maybe, but the second part is really high in our flagship apps. This is due to the total number of unique components being high and some nodes being repeated in many places.
Instead of such explicit code that we can rely on the Swift compiler to perform a second layer of safety checks for us with, we could create dictionaries at each component. Then we could rely on dynamic member lookup and then, at runtime, walk up the tree of components (to ancestors) and check on these dictionaries and check if the dictionary has the item we are looking for.
The total volume of code needle produces is O(average_number_of_items_in_the_dependency_protocols x total_number_of_paths_in_the_component_tree). At Uber, the first one is slightly high maybe, but the second part is really high in our flagship apps. This is due to the total number of unique components being high and some nodes being repeated in many places.
Instead of such explicit code that we can rely on the Swift compiler to perform a second layer of safety checks for us with, we could create dictionaries at each component. Then we could rely on dynamic member lookup and then, at runtime, walk up the tree of components (to ancestors) and check on these dictionaries and check if the dictionary has the item we are looking for.