Reputation: 51
Consider I'm using an GNU (or GPM) biginteger library that is of type mpz_t. However, I may use a different library in the future. I want my code to be easily changed when I use a different library, so I should not need to change all types of variables using mpz_t.
Thus, my question is whether it is a good OO design if I first define:
typedef mpz_t bigint;
then use bigint all over my code? If not, what other options could be used?
Upvotes: 1
Views: 117
Reputation: 73376
Here one can see the trade off between readability and the easiness for the developer. Some typedefs that aim to do what you describe are just awful, because they are not limited to a logical amount of types, thus it makes the code hard to read and maintain for others ... and you (when time passes).
You could give the typedef
a chance and see what happens. Consider using a separate file (but this is optional) to do all the manipulation you need when using another library (if this is applicable of course). Then you will have to check/modify only one file of your project (super-useful when the project is large).
Upvotes: 1