简体   繁体   中英

How to identify derived classes that is going to affect when base class is modified

If I modified base class, how can I know that which derived classes are affected. To elaborate more, for example, I have two base classes named Class A and Class B. I have Class X and Class Y inheriting from Class A, and Class Z inherits from Class B. Here in this case scenario, I have only 2 base class and 3 derived classes and it is manageable to see how they are interrelated. What if I have so many derived classes with so many base classes in real world enterprise application. How can I identify which classes are going to affect when I change base class. Thank.

In Visual Studio you would right click on the thing you want to change and in the popup menu select either View all references or View call hierarchy .

If you want to do it yourself in code you would use reflection for example as described in Discovering derived types using reflection .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM