开发者

Refactoring a C# derived class with method dependancies

I want to get your opinion on this.

I have a class which is derived from a base class. I don't have control over the code in the base class and it is critical to the system that I derive from it.

In my class I inherite two methods that are critical to the system and are used in pretty much every function, many times.

I intend to refactor this derived class and extract some classes from it - this won't be a problem. What I'm not sure about is, is it worth extracting class if开发者_如何学运维 I have to constantly make call backs to my main class to access the two methods (or public wrappers to the methods)???

Thanks


Not sure in your case but refactoring is for your benefit and others. You have to weigh the cost of refactoring with benefit of code up-keep. The point of method extraction (and not copy-and-place) is that it centralizes it and makes it easier to deploy changes. So it is probably worth it if you have the code everywhere.


Based on your concern about dependencies, it sounds like you'll probably have to let the "main class" continue to be the "front door" for now--i.e., the class that everyone calls. Let the main class delegate to the extracted classes, not the other way around. Without more details, that's all I can think of to say.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜