In the project I work on, we handle Medical Billing.
Every time the state makes a change to the official form (which our data classes represent), in order to maintain backward compatibility with previous forms, we add the new properties but leave the old ones intact, and have a document version property which is used to determine what validation is done and UI actions to display it.
This has lead to bloated classes over the life of the project (almost 5 years of State-mandated changes), and simply not supporting old document formats is not an option.
I would like to try creating a new class for each document version, but even then we will have several copies of very similar (though slightly changed) code. And class names such as ProgressNoteV16, ProgressNoteV17 look horrible.
Inheritance can't be used, because that would still result in the same problem (classes having properties that are no longer needed). Interfaces would make the Interface just as bloated, which wouldn't solve the issue.
What are the solutions and best practices used to solve this problem?
C# 4.0 is nearly backwards compatible with previous versions but there are a few breaking changes. For most ordinary code you won't notice these breaking changes. For the new features in C# 4 you can check out the Wikipedia article which has quite a good summary with examples.
NET Framework 4.5 and later versions are backward-compatible with apps that were built with earlier versions of the . NET Framework. In other words, apps and components built with previous versions will work without modification on the . NET Framework 4.5 and later versions.
ASP.NET 5 is just the new Web stack reimagined; it's not backward compatible, at least not literally, although it doesn't sound like a brand-new paradigm shift to ASP.NET developers.
Yes. By installing . NET Core Runtime 2.2. 3, you can run apps which target netcoreapp2.
This is a fairly classic problem for any agency that works with the public in any capacity, especially if its a government or government monitored agency. The solution is non-trivial, and it will probably require some significant work to create, as well as maintain afterwards.
This has worked for me in the past when dealing with similar issues for clients, it might not work for you though, you will need to draft out what your trying to accomplish and if it makes sense to do this.
There are a couple of patterns to be familiar with (if you arent already):
There are two books that are pretty good for explaining these (and a few other useful ones):
Now to the process I have used in the past:
Hope that gives you some ideas of what to do.
If inheritance can't be used "because fields in the document can be removed", how do you handle that at present?
Depending on the details of your design, you should be able to override the fields unused by the current version of the document (i.e. override in a subclass for that document) and throw a NotSupportedException or similar in the implementation of that method if the form tries to assign a value. By a similar logic, you can (and probably should) use interfaces... just knowing that a concrete implementation may throw an exception for a property that it implements but that is not defined for that version of the UI.
You can use the Factory Pattern to return an appropriate instance of the object for the given form version.
If there is some commonality between code that's slightly changed but mostly the same, you may be able to refactor some of that commonality into a private/protected method that is used by multiple public methods.
As for class naming, if you use the Factory Pattern you can refer to the class in most of your code using the interface. Only the factory itself would need to deal with "odd" looking class names.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With