简体   繁体   中英

C# Design Choice - COM object or just another class?

The existing software uses C++ to code the communication layer as a single object. Microsoft COM object is used to connect the communication object to the upper layer of the UI. It exposes interfaces using the COM object.

New software requires me to create a completely different communication object that is radically different from the existing communication object. I can either choose to code it in C# as a separate class or create another COM object and re-use some of the C++ code to create the object.

Being a C native, I want to hear your advices before making a decision on how this future software change should be made. I feel that if I create another COM object, it seems unnecessary as a C# class within the upper layer can handle it. But then I get to re-use some of the code.

Thanks!

I feel that if I create another COM object, it seems unnecessary as a C# class within the upper layer can handle it. But then I get to re-use some of the code.

There is no right answer here. If the amount of re-use is large, then sticking to the "legacy" method of using COM may be an appropriate choice.

If you're going to reuse 5% of your code, and have to implement the vast majority of this from scratch anyways, then a simpler API (just putting everything in the C# layer) is likely a better option.

That being said, it's completely up to you and your team to determine the best way forward. In general, using COM is going to make the overall design far more complicated, so that will need to be weighted into the cost/benefit analysis against the reusability of your existing code.

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