-
Notifications
You must be signed in to change notification settings - Fork 2
Mappings
To make mappings extensible, an abstract layer has been created to switch mappings easily within the logic. These mappings are managed by the InstanceManager and can be configured before using them.
The mapping interface can be implemented to make a mapping between two objects. An input and output type has to be defined when it is used.
Sometimes, variant mapping logic is necessary to map an object when it varies in certain properties. To select the accurate mapping for an object, the MappingSelector is used.
MappingSelectors are registered to the InstanceManager. When registered, they can be used by the app's logic.
The forms app registers these MappingSelectors to the InstanceManager in the Dependencies class.
Mappings can be requested from the InstanceManager by the var mapping = GetMappingSelector<T, U>().Select(T input) method. Then, map an instance by invoking var output = mapping.Map(input).
In some cases, some more complex input and/or output is necessary for a certain use case. For this, you can use IMappingDepends<T> and IMappingResult<T> interfaces.
There's a tutorial on another wiki on how to do this. You can find it here:
To change mappings, make sure you've followed the tutorial on creating new mappings first.
Instead of changing already existing mappings, it is expected to create new mappings and selectors, to maintain the functionality of the program. This way, the application can fall back on the other MappingSelector and Mappings.
You can remove the registration of a MappingSelector to the InstanceManager by simply removing it from the dependencies. Then, simply add the new MappingSelector you created.
Mappings make use of the strategy pattern. This is a behavioral design pattern that enables selecting an algorithm at runtime. The algorithm may vary independently from the classes that use them.

A class diagram showing the overall mapping structure.

The mapping algorithm can differ because the MappingSelector selects the appropriate algorithm for a given object.
Is there a way for monitoring mapping coverage, so that not one possible mapping is missed?
I think this is very hard to do because mapping is not simply 1 to 1 in all cases. Often multiple variables are used to construct a certain object. So simply testing whether every variable has been edited in the code, is not a solution.
You can write a unit test for every possible combination of variables, where different mappings are expected, which is a viable solution. But as both models evolve, these will have to be updated along with the mappings.
Another way to test the integrity of mapping is to write algorithms for both ends, checking if the behavior is the same. Although this is very time-intensive, it is a good way to validate software integrity.
This Wiki was created by Jurjen Verbruggen
- App Structure
- Pre-loading
- Translation
- Testing
- Eulynx Applications
- Considerations