Business Delete Rules

When you create a model, the deletion of objects is seldom at the top of your mind. Sooner or later, though, users are going to want to remove objects from the system executing your model.

The main problem with deletion is the question of what business rules the deletion should adhere to. The technical rules the deletion adheres to are covered by aggregation and the delete action described earlier here.

We have also added the IBusinessDeleteService that works like this. On every association end, you can set one of four values: NotDecided, MustBeEmpty, NeedNotBeEmptyButWarn, and NeedNotBeEmptyNoWarning. The default value is NotDecided.

Now, what you should do with this meta information is up to you. You are free to implement your own flavor of the IBusinessDeleteService, or you can just implement the IBusinessDeleteService.OnInformTheUser event on the standard implementation.

WECPOF implements this event and shows a dialog to the user.

Rules - 1 .png

When you have the BusinessDeleteRule set to NeedNotBeEmptyButWarn, you will get messages like these:

Rules - 2.png

If you have BusinessDeleteRule set to NotDecided, you get a message like this:

Rules - 3.png

If you have the BusinessDeleteRule set to MustBeEmpty, you get this:

Rules - 5.png

Delete Constraints

Furthermore, you may have explicit business rules that control if it is ok to delete an object or not – you can now handle these as normal class constraints. Constraints have been extended with an attribute IsDeleteConstraint. If this is set, the default implementation of the IBusinessDeleteService will call the OnInformUser event with the message constraint as a parameter. WECPOF uses this to show a dialog to the user and stop the delete until the constraint break is fixed.

This new service helps you feel in control and good about the deletion. It will not automatically solve all your delete issues – but we believe that it will enable you to solve them all easily as needed - Agile, so to speak.

This page was edited 108 days ago on 02/10/2024. What links here