❔ Handling different version changes for external standard.
Hey! I'm developing tools for a community to support OpenDRIVE standard. The name of the standard does not matter.
The standard is available in various versions, including: 1.4.0, 1.5.0, 1.6.0, 1.6.1, 1.7.0. For each version, the developers provide XSD files based on which I can generate C# classes to reflect the functionality of the standard. The standard describes a road network, so its example classes are Road, Lane, Geometry, etc.
How should I approach the issue of different versions of this standard?
Should I generate separate sets of classes for each version and keep them in different namespaces? For example, I would then have the class Road:
In my opinion, this looks very ugly. Maybe I should have one set of classes but somehow tag specific fields with attributes like
[Version("1.6.1")]
. This solution also seems weak, I wouldn't want to make an attribute for each field then. What then if a field meant something different in the previous version than it does in the new version?
It is worth noting that previous versions do not mean that they have become Depracated.
I have absolutely no idea how I should solve something like this. And how to call such a problem at all, so that I can search on the web.4 Replies
I'd probably have a common
IWhatever
interface, and a bunch of classes that implement it
Far as how to store it... I actually think a separate Git repo, with each version being in its own branch, and separate nuget releases generated from those branchesI wouldn't make it in separate branches, just keep it in one branch
@Angius
Ah, important things I didn't mention:
1. I would prefer to generate classes from the XSD file, so the implementation of interfaces does not particularly fit here.
2. The user may use different versions of the standard at once in his application, so he must have access to them on one branch of my tool.
3. I use deserialization to load the XML file with data into these generated classes.
Because of the third point, it comes out a bit that I should probably have a separate set of classes for each version of the standard.
Is the solution with the different namespaces I suggested above, i.e.
Standards.OpenDrive.160
where the last number indicates the version, a good one?
Or is there something better?
I am also afraid of too much copied code. And then how would I make a class that, for example, calculates the length of the Road and handles these calculations similarly for, say, version 1.6 and 1.7, but, for example, differently for version 1.5?
This is probably my main concern.
Some type of adapter or factory pattern?Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.