Dodgy thread subject, I know, but I can't find a better way to describe it in brief. What I'd like to know is the following..
In a user module, a lot of the functions return custom types. However, the custom types are Blitz versions of C++ Structs, so they do not automatically hold the same field values. Clearly there's an overhead involved in transferring data back and forth between struct and type. So, which would you prefer?
1) Module automatically transfers data from Struct to Type when a Struct is returned or data in one is changed, and vice versa with data from Type to Struct.
Advantages: Seamless operation. Cleaner code.
Disadvantages : Could occasionally be transferring data unnecessarily. Will mean a lot more work for me ( Don't count this :P )
2) Module manually transfers data from Struct to Type. You get a set of functions to do it yourself.
Advantages : Absolutely no unnecessary calls.
Disadvantages : Your code is a lot longer with a lot of calls to keep passing data back and forth. A single function call might end up being 3 or 4 commands instead of one.
3) Module never transfers data from Struct to Type. BMax types contain no fields, but instead have getters and setters to set and retrieve the values directly to and from the C++ struct.
Advantages : Absolutely no unnecessary calls. Will be faster than option 2 when you onlu need to get or set one or two fields in a type.
Disadvantages : Your code is a lot longer with a lot of calls to keep passing data back and forth. A single function call might end up being 3 or 4 commands instead of one. Will be slower than option 2 when you need to get all fields at a time.
Cards on the table, I think option 1 is the best. I believe the speed difference between 1 and 2/3 is negligible and the convenience and increased readability of your code is well worth it. It does mean a lot more work for me, but if I'm going to do this, I want to do it right.
Be interested to hear your preferences though.
In a user module, a lot of the functions return custom types. However, the custom types are Blitz versions of C++ Structs, so they do not automatically hold the same field values. Clearly there's an overhead involved in transferring data back and forth between struct and type. So, which would you prefer?
1) Module automatically transfers data from Struct to Type when a Struct is returned or data in one is changed, and vice versa with data from Type to Struct.
Advantages: Seamless operation. Cleaner code.
Disadvantages : Could occasionally be transferring data unnecessarily. Will mean a lot more work for me ( Don't count this :P )
2) Module manually transfers data from Struct to Type. You get a set of functions to do it yourself.
Advantages : Absolutely no unnecessary calls.
Disadvantages : Your code is a lot longer with a lot of calls to keep passing data back and forth. A single function call might end up being 3 or 4 commands instead of one.
3) Module never transfers data from Struct to Type. BMax types contain no fields, but instead have getters and setters to set and retrieve the values directly to and from the C++ struct.
Advantages : Absolutely no unnecessary calls. Will be faster than option 2 when you onlu need to get or set one or two fields in a type.
Disadvantages : Your code is a lot longer with a lot of calls to keep passing data back and forth. A single function call might end up being 3 or 4 commands instead of one. Will be slower than option 2 when you need to get all fields at a time.
Cards on the table, I think option 1 is the best. I believe the speed difference between 1 and 2/3 is negligible and the convenience and increased readability of your code is well worth it. It does mean a lot more work for me, but if I'm going to do this, I want to do it right.
Be interested to hear your preferences though.