4

So I'm currently working as an intern at a company and have been tasked with creating the middle tier layer of a UI rule editor for a analytical engine. As part of this task I have ensure that all rules created are valid rules. These rules can be quite complex, consisting of around 10 fields with multiple possibilities for each field.

I'm in way over my head here , I've been trying to find some material to guide me on this task but I cant seem to find much. Is there any pattern or design approach I can take to break this up into more manageable tasks? A book to read? Anything ideas or guidance would be appreciated.

Steve2056726
  • 457
  • 2
  • 6
  • 20
  • 1
    How is validity defined? There are several options, e.g. 1) Rule can be executed (is syntactically valid), 2) Rule can be executed and execution returns meaningful result (e.g. some data with some properties), 3) Rule is in compliance with predefined rules patterns. 1 is solved by parser, 2 should be easy to check, 3 needs some brainstorimg on what patterns are allowed. – Tomas Greif Sep 18 '13 at 14:31
  • Can you provide an example of the kind of rule you need to implement? – MattClarke Dec 18 '13 at 23:33

2 Answers2

0

You may consider to invest the time to learn a lexer/parser e.g. Anltr4. You can use the Antlrwork2 ide to assist in the visualization and debugging.

Antlrworks2: http://tunnelvisionlabs.com/products/demo/antlrworks

You can get off the ground by searching for example grammars and then tweak them for your particular needs.

Grammars: https://github.com/antlr/grammars-v4

Antlr provides output bindings in a number of different languages - so you will likely have one that fits your needs.

This is not a trivial task in any case - but an interesting and rewarding one.

WestCoastProjects
  • 58,982
  • 91
  • 316
  • 560
0

You need to build the algorithm for the same.

Points to be followed

1.) Validating for Parameters based on datatype support and there compatibility. 2.) Which operator to be followed by operand of specific datatype. 3.) The return result of some expression should again be compatible with next operand or operator.

Give a feature of simulating the rule, where in user can select the dataset on which rule has to be fired.

eg

a + b > c

Possible combinations.

1.) A, b can be String, number or integer. 2.) But combination result of a+b if String then operator ">" cannot come.

Ankur Singhal
  • 26,012
  • 16
  • 82
  • 116