Reputation: 43
I use ES6 extends
frequently in projects, sometimes I modify the parent class, but forget to check its child classes (as the increase of developers, things seemed to get worse). Maybe someone couldn't know if the class
has been inherited anywhere.
Are there any tools or ways which could help me to check the inheritance relationship of classes?
Upvotes: 0
Views: 106
Reputation: 71
(Can't comment yet, so posted as an answer.)
instanceof is as close as you're going to get.
Also, bug-a-lot isn't wrong. Unit testing would go a long way in preventing such regressions.
Upvotes: 0
Reputation: 2454
Unit Tests
Unit test your code! If a superclass changes behavior, it will likely break a unit test, so you know you messed up and you know to correct the offending subclasses.
If it broke functionality in your application, but not one of your unit tests, then your unit test coverage is not good enough, or you've missed some scenarios.
That's the number one thing you should do before any kind of refactoring! Unit test, unit test, and again unit test!
Text Search
If you're using any fancy IDEs you could search through javascript files for something like "extends MyChangedSuperClasss", assuming you colleagues don't use an arbitrary number of spaces between the keyword and the class name.
If you're not using a fancy IDE try to find a file manager that offers text search functions.
Upvotes: 1