Regarding Dynamic Implementation in a workflow engine

R

Ravi Shankar

Hi all,

Please help, thanks for your valuable time.

We have a workflow engine implemented in certain language. There is an admin
console for the workflow. With the help of admin console we can predefine
the sequence and set of classes to be executed, whose names are stored in
the database. At run time, depending on what configuration is required, the
workflow engine retrieves the class names from database, intsntiates and
invokes the method using reflection.

I had taken the project, and immediately I told that dynamism in object
oriented systems is not implemented in this way, we have interfaces and
implementations. I proposed an interface called "Service" (with a method ,
say "invoke"), which will be implemented by all actual service classes, say
ServiceClass1, ServiceClass2 etc.WHen application begins, all ServiceClasses
will be added into a "MAP". Then from database I take the serviceclassname
and call invoke dynamically without reflection. Is this fine? Any better
implementation, any majo flaws and any suggestions, please advise, thanks

Best regards,
Ravi
 
L

Lee Fesperman

Ravi said:
Hi all,

Please help, thanks for your valuable time.

We have a workflow engine implemented in certain language. There is an admin
console for the workflow. With the help of admin console we can predefine
the sequence and set of classes to be executed, whose names are stored in
the database. At run time, depending on what configuration is required, the
workflow engine retrieves the class names from database, intsntiates and
invokes the method using reflection.

I had taken the project, and immediately I told that dynamism in object
oriented systems is not implemented in this way, we have interfaces and
implementations. I proposed an interface called "Service" (with a method ,
say "invoke"), which will be implemented by all actual service classes, say
ServiceClass1, ServiceClass2 etc.WHen application begins, all ServiceClasses
will be added into a "MAP". Then from database I take the serviceclassname
and call invoke dynamically without reflection. Is this fine? Any better
implementation, any majo flaws and any suggestions, please advise, thanks

Given the information you've provided, your solution is the better one. Reflection is
too complex and not as efficient and not really OO. You might also choose to load your
ServiceClass sub-classes lazily.
 
H

H. S. Lahman

Responding to Shankar...
We have a workflow engine implemented in certain language. There is an admin
console for the workflow. With the help of admin console we can predefine
the sequence and set of classes to be executed, whose names are stored in
the database. At run time, depending on what configuration is required, the
workflow engine retrieves the class names from database, intsntiates and
invokes the method using reflection.

There aren't enough details about the specific problem space to say for
sure, but this sounds like standard parametric polymorphism where the
configuration of specific instances and relationships is defined in
external data (the DB) and Factory design patterns are used to implement
the configuration at run time. It sounds like exactly what the GoF had
in mind when they came up with the various construction patterns. The
Factory is just getting the initialization data from the DB rather than
from other objects. IOW, it sounds good to me. B-) OTOH,...
I had taken the project, and immediately I told that dynamism in object
oriented systems is not implemented in this way, we have interfaces and
implementations. I proposed an interface called "Service" (with a method ,
say "invoke"), which will be implemented by all actual service classes, say
ServiceClass1, ServiceClass2 etc.WHen application begins, all ServiceClasses
will be added into a "MAP". Then from database I take the serviceclassname
and call invoke dynamically without reflection. Is this fine? Any better
implementation, any majo flaws and any suggestions, please advise, thanks

Both approaches seem like overkill to me. Don't use inclusion
polymorphism to create complex dynamic mapping schemes just because it
is there. While it is often very useful (e.g., all the GoF patterns
make use of it), there is a downside. Because it requires static
subclassing, you can't change the structure by simply modifying the DB
data. It is also less intuitive than peer-to-peer collaboration over
simple associations and it opens the door for obscure LSP problems.

IOW, until there is a demonstrable need, KISS applies. Figure out what
objects and collaborations you need to solve the problem and only then
worry about how they get instantiated. If basic GoF construction
patterns apply, then use them.


*************
There is nothing wrong with me that could
not be cured by a capful of Drano.

H. S. Lahman
(e-mail address removed)
Pathfinder Solutions -- Put MDA to Work
http://www.pathfindermda.com
blog (under constr): http://pathfinderpeople.blogs.com/hslahman
(888)-OOA-PATH
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,431
Messages
2,571,679
Members
48,796
Latest member
Greg L.

Latest Threads

Top