4 ms·
Sure, it only affects you. The problem is that changes to superclass can now break your code. For example, perhaps right now the function looks like this:
by winstonewert 11y ago
Sure, it only affects you. The problem is that changes to superclass can now break your code.
For example, perhaps right now the function looks like this:
def get(self, url, method='GET'):
...
def post(self, url):
self.get(url, method='POST')
You override get, to add some additional functionality. All is fine.
Then somebody realizes that the original code was silly, and rewrites it:
def get(self, url, method='GET'):
if method != 'GET':
print "DEPRECATED!"
self.request(url, method=method)
def post(self, url):
self.request(url, method='POST')
It seems to do the same thing, and probably passes all the same tests. But suddenly, now your code doesn't get called for post requests and your additional functionality breaks in a mysterious way.
Perhaps its still your fault for doing a bad job subclassing, but its going to look like its the fault of the person who fixed the parent class.
- dplgk 11y ago> changes to superclass can now break your code The same exact thing happens when using composition.