If I must iterate over many game objects in a for loop to call a function in a component, and all the objects are very different, what should the scripts use?

Would anyone know how to go about answering this question? Any help is greatly appreciated.

@Myles23 I asked that same question and a guy on Discord told me this:

They will need to either implement the same interface or derive from the same base class
,@Myles23 I asked that same question on the unity discord and the guy answered this:

They will need to either implement the same interface or derive from the same base class