2

I am working on a project that now needs business rules. One design discussed is to make API calls (based on the form we are on) which responds with business rules for form input. I am unsure if this is the best way. The business rules are in JSON, but the business rules server actually has a business rules engine (so the engine crunches the rules and spits out JSON).

Some background:

In our web app, various forms exist, such as for logging in, registering, editing a profile, etc. Maybe 25-30 forms. They are content managed.

For any of these forms, various rules exist to show or hide fields, or present error messages on the form based on logic such as a field name being too long, too short, or not meeting a regular expression. Other things such as required field validators, etc, exist.

The idea was to have everything centralized in a different environment (as mentioned above...on the business rules server).

I am concerned about making so many calls to a server to get simple rules like a first name being required, or showing or hiding a button based on if a person sells a certain number of widgets, etc.

Perhaps a better solution would be to have this rules engine publish to our server, and we just call the local server rather than make API calls from the front end each time.

What does everyone think? Is it natural to make API calls from our .net forms (using jquery) to get our rules for each form, each time?

Thanks!

1

You will have to answer several questions in order to know what will work best. These are in no particular order.

Are your business rules static based on the question/field being shown/hidden?

If they are static, you can cache the business rules locally (on the page or server as appropriate). If they aren't, can you determine what the output difference is and then cache that? Also, how often do the rules change?

Can the value(s) selected/entered affect another field's business rules?

If I choose a truck instead of a car, will I still be allowed to select a hatchback type of vehicle? Should an electric motor driven vehicle have a choice for numbers of cylinders for the engine?

Does your validation change based on values selected/entered?

Selecting car manufacturer A sets your VIN validation to some number of letters, followed by some number of digits, where manufacturer B has letters, numbers, a couple of glyphs, and more numbers.

Does your data change based on values selected/entered?

Cascading dropdowns are very common for this type of item; manufacturers listed in the first dropdown, models in the second.

Where will the application be run?

If it will be on your network, it is possible that your throughput will be sufficiently fast that you don't need to consider caching. You may also have caching routers between you and the business rule server that will limit the number of calls to the business rule server.

How many users will be using the application?

If this number is small enough, then the added expense of caching will probably not be worth it.

How much network overhead will the application add?

You are going to have to measure this. It will depend on more factors than I can list here easily. Ask yourself if the trade off in bandwidth is worth the difference in added complexity of your application.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.