Question

I have been working with quickfix and Visual Studio and see that I can initialize an instance of FIX42::NewOrderSingle from a FIX41::NewOrderSingle with no compiler issues or even issues during runtime. The same is true when I have a method with a parameter such as FIX::Message and I can pass in a FIX41::NewOrderSingle or FIX42::NewOrderSingle with no issues. This enables me to not need to create overloaded methods for each type parameter. Is this a good thing to do? Or am I asking for trouble? Thanks

Was it helpful?

Solution

You can pass FIX::Message as a parameter but you will not be able to use the generated typesafe field accessors. That's not necessarily a bad thing if you need flexibility more than type safety but it means you must be more careful in how you access and interpret the message data.

The FIX::Message constructor that takes another FIX::Message copies the source message's internal FieldMap from one message to another. This will probably work reasonably well for two NewOrderSingles from different FIX versions but be careful about fields that have had their type modified between versions or don't exist in one version or the other. You can actually construct any generated message using a constructor that takes any other subtype of FIX::Message. However, if the messages are unrelated this probably isn't useful since the fields if the source messages may not be valid for the target message although it won't cause a compile-time or run-time error.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top