Search code examples
rubyclassinstance-methodsclass-method

Ruby classes that provide identically named class and instance methods


For flexibility, I've seen some APIs w/ classes that provide identically named class and instance methods.

Are there any reasons as to why this might be a bad idea?


Solution

  • That is at the heart of object oriented programming. It is called polymorphism. It is a good practice. Denying that would be denying object oriented programming.

    It saves the brain power of whomever reads or writes the code. You would have to remember less methods, and you don't have to switch between them.