Even though an editable object and read-only object might have similar properties, it is unlikely that any of their code is in common.
Even the property code is different, because the editable object will have read-write properties and the read-only object will have read-only properties.
The editable object will have business and validation rules, the read-only object won't.
They both might have some authz rules, but the editable object will allow/deny write, and the read-only object won't.
So in the end, the only code that might be close enough to reuse would be your data portal fetch method. There are several ways to build a data access layer that would allow reuse of the data retrieval code to load two different objects with the same (or very similar) properties.
If your DAL returns a DataReader, and the objects have very similar properties, you could get away with loading both objects from a common DataReader (reuse the same DAL method).
If your DAL returns a DTO, and the objects have very similar properties, you could get away with loading both objects from a common DTO (reuse the same DAL method).
And I'm sure there are other variations on that theme - you could use reflection, etc.
Copyright (c) Marimer LLC