Comments inline
On 09/15/2011 11:09 AM, Vivek Singh wrote:
Important points in the link (this is a wiki managed by
multiple people, hence the lack of clear cut argument):
But I think we have good answers to those questions, and like you
say the wiki doesn't really take a clear stance on the issue. In
fact it doesn't even define the issue. Are we talking about Passive
or Active code generations?
>> If the generated code will never be
touched by humans, then why not "run" things off the
original input instead of the outputted code?
1) The humans who will write the original code may not be capable of
writing the generated rules
2) We can provide compile time checks on the original code as
opposed to execution time checking on the generated rules
3) The original code is a superset of the rules engine since it also
allows the specification of alert schedules
4) The rule engine doesn't run off the original input
I'm sure there are more those are just off the top of my head.
>> The input to the code generator is the
higher abstraction that is being converted to a lower
abstraction: the output code. Why is the input to the code
generator not sufficient in itself?
For the reasons listed above. However you could also say this is
the same reason why we are writing the app in Java and not byte
code.
Generating mark-up is trying to solve essential (not
chosen but present) complexity of language mismatch. In-fact even
there a template approach is preferred to keep the mis-match to
minimum, as against generating entire HTML.
I would be very disappointed if we did not use templates to generate
the rules. Again I really see this as no different. We have an
interpreter (browser == rules engine) and we need to generate input
for it.
The complexity of generating rules is not essential,
is chosen by us as a design. "We have a rules engine" doesn't mean
we have to use it.
First I question that the generation of the rules is complex. This
should be a fairly straight forward using a template. Additionally
we have a solution that maps perfectly to the problem. This is a
logic problem that we are trying to use data structures and
algorithms to solve. Choosing to write code that you don't have to
is rarely a good engineering choice.
Message that loops can be better handled using appointments
module. (Going to dentist every 6 months for rest of life). We
don't have to solve every problem using this. Besides if it can
specified in json config then it can be handled in Java code as
well.
"Anything you can do by generating code, I can do by
calling data driven subroutines."
I'm not talking about going to the dentist. I'm talking about each
day we expect an input from some remote system, then an output to
different remote system followed by two other actions that can occur
in any order. That isn't something you can do with the apt module
but is something you could do with this module if it allowed loops
in the schedule.
Again just because you can do it by calling data driven subroutines
doesn't make that the best engineering choice.
I don't like our xmind approach and was done in a hurry.
Ideally we should be reading the xmind as a configuration and
constructed decision tree objects at runtime. That would been
more extensible. In today's call Aakash was asking whether he
can change the xmind and would it work. It wouldn't because
every time we would have to manually add code to the generated
code.
Why doesn't the xmind XML get converted to the JSON that is the
input to the decision tree? If it was done that way then Aakash
could update the trees.
So it is not a ideal example to follow.
Ok, then what about Spring Roo, annotations or aspects? :)
Essentially it suffers from problem mentioned in the link:
(
It's only a problem if you need to muck around with
the generated code after generating it (which would violate OnceAndOnlyOnce because
it would require mucking around after every time you
generate it from source).)
Generating significant blocks of code to be
customized for each use is BAD.
Again if we went xmind -> json we wouldn't have this problem. It
is since you are going xmind -> code that you do. Similarly we
are going json -> rules not json -> code so changing the json
allows for regeneration of the code without the issue you mention
above.
-Rob