Enumerating Business Objects. Xafari Numerators | Xafari Framework

xafari numerators

Business applications designed for big enterprises, and especially the ones that, among other things, are to handle document flow, often require complex enumeration functionality that will enable generating and assigning numbers of certain formats (usually including an increment part) to business objects. The rule for number generation is defined by the internal rules applied in the company and its business processes, so the number format may include various elements such as the date or its parts, business object type, department it was created in etc.

There are two basic approaches that developers tend to follow when creating such functionality: either strictly define the rule of generating and assigning numbers in the code or try and create a universal field enumerator that will allow defining enumeration rules during application designing or running phase. The former is faster and simpler to develop, but in case the company changes its internal rules by which the number of certain business entities should be generated, the developer will need to change the code accordingly. The latter will not require such changes but is harder to develop and often results in field enumerators that are too complicated and not convenient to use.

We decided to single out some solutions that allow implementing either or both of these approaches while at the same time eliminating or whittling down their principal drawbacks.

The first approach of developing enumeration functionality in XPO applications is defining the strict rules to generate sequential numbers during the application development phase. Whether you do or do not use XAF for development, you have several possibilities to generate a sequential number for a business object. One of them is using ExplicitUnitOfWork. DevExpress wrote rather detailed guidelines on how to use it for different types of applications. In case you use XPO without utilizing XAF, you can follow this instruction for generating sequential numbers for business objects during the saving process. You can also use this pattern while working with XAF, but there is another, quite similar solution, which is more suited for this framework. Both these approaches will enable generating and assigning increment numbers to business objects while inheriting from a common base class.

In case you do not need to inherit from a common base class, you can use DistributedIdGeneratorHelper to implement the same functionality. It is simpler to develop as compared to the two other examples and requires less coding.

If you need to create a less strict and more universal field enumerator that will allow application users or administrators define the enumeration rule and customize it to the changing business processes in their company themselves, you can use Xafari Business Numerators.

It contains the template according to which the number is generated and assigned when a new business object is created. In this case, the rule for generating and assigning numbers is defined on the customer’s side: the administrator creates the rule when deploying the system, and if the rule changes the administrator can customize it in the module without the necessity to change the code. In this case, no coding is required from the developer’s side at the designing time. However, the developer must activate the module in order to enable its usage during the running time.

In a case of necessity, the developer can also expand the existing functionality of the enumerator and implement custom features in code using this guidance.

Read more about Xafari business numerators and their functionality in the documentation.