ITeye博客

Change Ugly code in our project

lua · 2009-11-23 17:48 · Markdown

following code happens many times in our project:

 

                        xxxxxxx;

#if defined _ETHERNET
                        tmp1String = deviceKey.GetAddressAsString();
#else
                        tmp1String = deviceKey.GetNodeAsString();
#endif
                        yyyyyyy;

 

 

It should be changed like:

 

CString GetAddrString(DeviceKey& deviceKey)

{

        CString tmp1String;

#if defined _ETHERNET
                        tmp1String = deviceKey.GetAddressAsString();
#else
                        tmp1String = deviceKey.GetNodeAsString();
#endif

        return tmp1String;

}

 

then we could use the function like:

 

     xxxxxxx;

     tmp1String = GetAddrString(deviceKey);
     yyyyyyy;

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。