zmqpp
zmqpp copied to clipboard
Branch for different zmq versions / Code Simiplification.
We have a lot of #ifdef sections in the code for different versions of the code base, however we only actually do test builds with 3.x, 4.x and 4.1 builds of zmq. Would it be worth stripping most of these from the codebase in an effort to simiplify the code for future maintenance?
We could either branch for the 3 and 4 version to match the libzmq-3.x and libzmq-4.x repos or something similar along those lines.
Hello,
Yes we indeed have a lot of #if. Around 125. I'd tend to agree that we have too much of those.
Cleaning up a bit would be nice for future development.
However I am not sure that branching is the way to go:
- As a end user I think it's great being able to not care what branch we pulled and know that it will compile no matter the underlying libzmq (assuming we support it).
- While it would ease support for libzmq's version specific code (new option in libzmq's master for example), for general dev it would require us to port each change to each branches.
Note that I don't have a strong opinion against doing this, but these are the drawback I can think of.
An other idea would be to template the socket class (and any needed class) for each version of libzmq and specialize the template when needed (setting/getting socket option for example). We'd need to provide a typedef so that it's transparent to the end user. I am not sure how well (if any) this would work.
As a side note regarding future maintenance / long term development. I think we would benefit from a written / enforceable (clang-format ?) code style guideline. The code base it's that big yet we have at least 3/4 style cohabiting (and I know I'm partially responsible for this mess).
We should have some kinda of enforceable (or at least warning generating) style guide, although I don't actually know how to do that. I imagine it will also mean we have to restyle some of the code to achieve it, but that is probably a good thing.