ZeroSharp

Robert Anderson's ones and zeros

Migrating a Large Web Application From XAF 12.1 to 15.1 - Part 2

| Comments

This is the second part of a series about migrating a large application from XAF 12.1 to XAF 15.1.

In the 13.1 release, DevExpress made a change to the way XAF Validator class is used. It now requires an IObjectSpace parameter corresponding to the object. It is needed to correctly evaluate any rules which are descendants of the RuleSearchObjectProperties. These include:

  • RuleCombinationOfPropertiesIsUnique
  • RuleIsReferenced
  • RuleObjectExists
  • RuleUniqueValue

A lot of our code has been around for years now and the older parts rely heavily on Session and UnitOfWork instead of IObjectSpace For the most part our application used IObjectSpace only within ViewControllers.

But there were several situations where we need the validator where we don’t have an IObjectSpace. For instance we sometimes need to validate from within method actions (decorated with the ActionAttribute). For performance reasons, we pass criteria to our middleware and it uses a UnitOfWork to run the method on each object. So in this case, there was no IObjectSpace to pass to the XAF Validator.

Here I had a refactoring dilemma to solve. Either I need to rewrite all of the affected rules so that they no longer make use of the IObjectSpace. For instance, I could use RuleFromBoolProperty instead. In our application, this would mean rewriting about 50 rules. Or alternatively, I could go through the entire code base looking for new UnitOfWork() and new Session() and try to use an IObjectSpace instead. When writing code I often find myself having to decide between the ‘quick’ fix and the ‘right’ fix. Here, moving to IObjectSpace throughout is clearly the right fix and although it would take more time to implement, the system will be more in-line with best XAF practices throughout.

Eventually, the refactoring was complete and all unit tests are passing. I was eager to run a multi-user load stress test against the 15.1 version to compare performance under load. I have described in previous posts how to stress test XAF applications. I’ll be sharing the results in the next post.

Comments