سؤال

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?

هل كانت مفيدة؟

المحلول

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.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top