Well, that’s why we have a utility inside the company that generates business model classes from our tables and database representations, similar (but not entirely accurate) to ORM. While maintaining it, it occurred to me that the data in the circuits are unlikely to change as a whole. However, functionality may be. We might want to add extra features along the way. We may want to generate some of these functions, and we can extend it.
The classes we create will be in the class library for consumption by other libraries and applications. No big surprise. But now is the time to create the generated classes so that we destroy as little code as possible when we restore the class. If, for example, code is added to a property (which represents a column in a database table), we do not want to lose it.
So, there are two approaches that strike the head:
Classical inheritance , where all this is done in one "monolithic" class, and consumers can redefine the basic implementation. From time to time it becomes quite difficult, and often introduces headaches. In addition, if the derived class is not careful and forgets to invoke the functionality of the base class, things can get loose quickly.
Partial classes . In this diagram, we divide the business object into separate parts: properties (which are mapped to columns) and behavior. Behavior can even be further broken down into generated behavior and user behavior. The problem with this approach, as you can see, is related to its complexity. In addition, there is a naming problem.
Here's my question for you: when you are dealing with a scenario like this (if you have ever been), or if you were presented with such a scenario, what solutions would you consider and why?
Mike Hofer Jun 26 '09 at 17:53 2009-06-26 17:53
source share