問題描述
為不同版本的 3rd 方庫設計實用程序 (Design of utilities for diffrent versions of 3rd party library)
我繼承了一個應用這種解決方案的項目:
有 5 個版本的 3rd 方庫。解決方案中有 5 個項目,其中包含相應版本的 3rd 方庫的實用程序。
解決方案中的很多實用程序類對於所有版本的 3rd 方庫都有相同的代碼。這樣就解決了重複問題——所有項目需要相同的代碼文件存儲在某個公共文件夾中,並作為鏈接添加到所有項目。
我不覺得使用鏈接共享代碼是最好的方法。您能否告訴我這是否是一種不好的方法,如果是,請告訴我 .resolve 此類代碼重複的正確方法是什麼?
提前致謝。
參考解法
方法 1:
It's fairly subjective as to whether this is 'bad'.
Linked code files are possible for a reason ‑ sometimes it is necessary to share files like this between multiple projects.
Depending on how different the third party library is between versions ‑ it might be possible to write some wrapper code which deals with these differences and isolates this away.
(by ika、user111013)