views:

136

answers:

2

I've got a system that has Java server side objects and C# client objects. The objects can be modified in both sides of the system and so have business rules attached to them. The thing is currently the business rules only live on the server side, and I really want to avoid having to contact the server every time I want to verify the objects.

So ideally I want to have shared business rules that can be used in both C# and Java, so when a change is required I only apply it in one place (and obviously deploy in 2).

Has anyone any suggestions on how I could go about this?

+4  A: 

This may sound terrible at first, but you could in fact consider coding the business rules in javascript.

There are javascript engines available both on the java and .NET platform. That way, by hosting a (different) javascript engine both on the server (java) and client (C#), they can both execute the same javascript to enforce business rules.

Think of it as your business rules language of choice. It's not a bad choice for the task either, as it is terse, flexible and well known.

I have done something similar once, to set up flexible game rules in a java-based game. Javascript engines are surprisingly simple to set up, and nowadays they're getting pretty fast too.

Tor Haugen
An interesting idea, I'll have a look into it :)
John Mc
It's been a while, but this worked out alot better than the IKVM :)
John Mc
+2  A: 

Try using IKVM

hjb417
Hey, that's cool.
Tor Haugen
Cool, I'll have a look at it :)
John Mc