开发者

Do you have advices about how to wrap an internal library to deliver it to a client?

In my company, we are using a cross-platform utility library offering a lot of services.

This includes both cross-platform code (e.g. a thread class wrapping either Win32 or pthread API) or every company specific code (e.g. classes to handle proprietary communication protocol between our servers and our clients applications).

We need to deliver part of those features to a client, which agrees to use the same compiler and compiler options than used by the library.

Currently, my design is centered about making sure each version of our library will have its interface be binary compatible with the previous ones:

  1. Delivering a DLL/SO library
  2. Using simple and clear naming conventions (inspired by Java camelCaseNaming, etc.)
  3. Use of the STL
  4. Use of a global namespace (and prefixing any macros with non ambiguous name to avoid name collision)
  5. PImpl-ing every classes that needs to be used
  6. Doxygen-ing everything (and giving the "public part" to the client)
  7. Simplifying and unifying our 开发者_Go百科interfaces
  8. No virtual methods in our PImpl classes
  9. No inlined code unless exception (even constants are exported constant values, defined in the compiled source, and simply declared in the public header)
  10. Exceptional inline code for utility/indirection functions without much code inside (e.g. the swap function would be inlined, calling the non-inlined swap method of the object it swaps)
  11. Exceptional inline code for some simple "value classes" without real code, to avoid unnecessary overhead (e.g. a complex number class would be inlined)
  12. Offering high-level services (calling the PImpl-ed classes described about) through inlined code (meaning the client can reuse/modify it to his own needs)

Is my list complete, or did I miss something which would simplify future maintenance/evolution ?

Is one of my points a mistake ?


Facade Pattern

I've used it to create "programmatic interfaces" to large sub-systems. Create one or more based on need.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜