[英]C++ Refactoring, Extension Methods typedef
我有一個舊版 c++ 應用程序並逐步對其進行重構。 我遇到了很多 typedef 如下
typedef std::vector<class OrganisationData *> VECTP_ORDATA;
VECTP_ORDATA g_OrganisationData;
目前 g_OrganisationData 上有很多免費功能。 What I feel is, previous developers should have made a class and made it more object based instead of free function spreaded everywhere.Currently I am in a process of grouping relevent functions together and make it as a static class around g_OrganisationData
and call static functions whereever必要的。
另一種選擇是將 function 組合在一個 header 文件下並使用它。 還有其他最好的選擇嗎? 由於代碼的性質,我不能只一步一步地進行更改。
我的建議是將相關函數放在適當命名的命名namespace
中,而不是讓它們成為class
的static
成員函數。
例子:
namespace RenderAPI
{
// Put all rendering related functions here
}
namespace PersistenceAPI
{
// Put all read from disk and write to disk functions here.
}
namespace MySuperCoolBusinessLogicAPI
{
// Put all the functions dealing with your super cool business logic here.
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.