0

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?

3
  • What kind of change are we talking about? Adding functionality, changing behavior, removing functionality? Commented Jan 10, 2017 at 14:17
  • @bug-a-lot: In react-native Component, maybe change the render method, also include any other things in a Component. Commented Jan 10, 2017 at 14:30
  • npm uses versioning for this sort of thing Commented Jan 10, 2017 at 15:19

2 Answers 2

1

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.

Sign up to request clarification or add additional context in comments.

Comments

0

(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.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.