visitor pattern it is necessary to mention martin fowler' take on developing micro service-based architectures fowler posits that one first has to develop the monolith because at the outset you do not know which elements will coalesce to form good micro services and which can be kept separate as you work on and grow systema single object becomes network of objects when these networks become too complexyou refactorseparateand clean up the code in ways that would not make any sense at smaller scale this is another high-level instance of the you ain' gonna need it principle (yagni)which simply implores the developer to not build functionality or structures that will not be used this is much like the young developer who upon creating new object immediately proceeds to add createreadupdateand delete functionality even though the object can never be updated (or whatever business rule appliesimmediately abstracting any function or idea into some sort of meta class will leave lot of dead code in your systemcode that needs to be maintainedreasoned aboutdebuggedand testedbut never actually used new team members will need to slog through this code only to realize after the whole system is analyzed that it was waste of time and effort if this type of code proliferates the systemthe push for complete rewrite will become strongerand more time will be wasted if dead code is again implementedthe new developers will head straight into the same problem in shortdo not write code you are not going to use good rule of thumb is to wait until you have to do the same thing (or very similar thingthe third time before you abstract it the flip side of this rule is that as soon as you come across the same requirement or problem in your project the third timeyou should not proceed without abstracting the solutionso that whenever you next come across this situationyou will have solution ready to go you have now found balance with this in mindimagine that you have needed to alter objects twice to allow some function to be performed over the entire collection of objectsand now you have third algorithm you want to implement specific to the structure clearlyyou want to abstract the algorithms being implemented in terms of the data structure ideallyyou want to be able to dynamically add new algorithms and have them be executed relative to the same data structure without any alterations needing to be made to the classes that make up the elements of said data structure