0

We have the following task:

We have a complex, hierarchically structured user model (persisted in YAML, available as objects with attributes in RAM). This user model has to be checked against some constraints (“validate”), and it has to be “compiled” into a model optimized for the runtime (runtime model).

The “compiler” has to do e.g. the following

  • Map attributes between the two models
  • Combine n user model attributes to one runtime model attribute (and the other way round)
  • There is no 1:1 relation between the objects – 1 object in the user model can result in n objects in the runtime model (probably not the other way round)
  • Do some calculations (mainly bit operations) on the user model attributes resulting in one or more runtime model attribute
  • String operations (e.g. add a fixed string in the beginning of a string)

The “validator” has to do e.g. the following

  • Check direct constraints between attributes (like _max >= _min)
  • If attribute a exists, also attribute b, c and d must exist
  • The allowed values for attribute b depend on the value of attribute a

Other checks like

  • Specific ranges for attributes (e.g. enums)
  • References to other objects must exist, and they must be of a specific type

are already contained in the model description and are considered as syntax errors, whereas the validation checks the semantics.

Both the compiler and the validator should be generic, that means, they should work based on files describing the validation and conversion rules, and there should not be a need for writing additional code if the model is changed. Generating source code based on these description files would be OK (and most probably makes sense to increase runtime performance).

What we already found and will have a look at: http://automapper.org/, https://github.com/omuleanu/ValueInjecter, https://www.eclipse.org/Xtext/index.html, https://fluentvalidation.net/, but esp. regarding automapper there are controversial discussions when you should use what. So it would be great if you could give us some advice here – thanks!

Some constrains:

  • As always, performance matters quite a lot, so it must be fast (sorry, I know this is not a very specific requirement). We are talking of up to 1 Mio objects, lets say with ~20 attributes on average
  • The “compiler” and the “validator” should be able to run under windows and linux

Any help would be greatly appreciated!

Thanks, Klaus

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.