Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

How to decide which implementation to use?

by ruoso (Curate)
on Feb 24, 2006 at 21:03 UTC ( #532672=perlquestion: print w/replies, xml ) Need Help??

ruoso has asked for the wisdom of the Perl Monks concerning the following question:

In the Web Services world, everything is about standards to follow (web services are not just RPC). In practice, some agent (the name given to the code that implements something) implements some Interface (in the OO sense).

While designing an application server... I faced a problem... The application server I'm talking about will be composed by a "Kernel", that will receive the register requests for each "Agent" loaded by the application. Like....

# The Oak2::Kernel namespace will be populated by # some Kernel implementation. The idea is that # Oak2::Kernel is just an API that anyone can # implement. Oak2::Kernel::LocalAgentsOnly->load(); # The following code will load two agents, that will # automatically register itself in the Kernel. Some::Agent->load(); Another::Agent->load();

Now, let's suppose this two different agents provides the same interface... Let's say "http://www.example.com/some/interface". The question completely open is: What would be returned when the user looks up for this interface like...

# This is how it's possible to get any object # anywhere inside the application server... my $impl = Oak2::Kernel->lookup("http://www.example.com/some/interface +");

So, what $impl would be?

  • Nothing, Oak2::Kernel would throw an error explaining the user should use a method specifically for multi-implementation interfaces.
  • A list or arrayref containing all the implementations for this interface.
  • One of the two implementations, randomically selected...
  • One of the two implementations, based on some rules (which kind of rules?)
  • A proxy object which would propagate all messages to all implementations.

Well, all here is nothing but sketches, so any suggestion is more than wellcome, including its-all-wrong-this-way-would-be-better ones...

Hope you can meditate more than me...

daniel

Replies are listed 'Best First'.
Re: How to decide which implementation to use?
by samtregar (Abbot) on Feb 25, 2006 at 00:45 UTC
    Take a step back. Do you really need to build something this abstract? If it's so abstract that you're unable to answer simple questions about how it should behave that's a good hint that it's too abstract to be useful.

    Well-designed OO systems speak the language of their problem domain. Assuming the problems you're trying to solve don't involve "kernels" (of corn?) and "agents" (007?), you're probably heading too far into abstract implementation, in my opinion.

    -sam

      IMO, in some contexts, this could be construed as false laziness. Someone somewhere has to speak in these terms. To say that if you're talking about kernels and agents that your level of abstraction is too deep discounts this reality.

      thor

      The only easy day was yesterday

Re: How to decide which implementation to use?
by kvale (Monsignor) on Feb 25, 2006 at 00:04 UTC
    I think implementation here really depends on the use cases for your system.

    Thinking of Apache as a kernel and innumerable web browsers as agents, Apache creates a pre-forked server design and assigns each agent request to a single child process. This load balances and implicitly assumes that all child processes are equivalent in capability. A caching proxy server would give priority to the fast cache implementation first, and would only assign a slow main database lookup second.

    Without knowing more about your problem, I would recommend prioritizing implementations according to time and space usage, picking the cheapest available inplementation first. If there are to be many implementations sitting at the same URL, arrange for the kernel to spawn a processes like Apache to handle just one agent request per child process and keep listening for others. You will better be able to manage kernel performance if it is the kernel that is managing service requests, not the agents.

    -Mark

Re: How to decide which implementation to use?
by renodino (Curate) on Feb 25, 2006 at 01:27 UTC
    "Go REST, young man. go REST!"

    Sorry, I couldn't help myself...I should never post on Friday evenings...

Re: How to decide which implementation to use?
by rvosa (Curate) on Feb 26, 2006 at 08:54 UTC
    I would say:

    A list or arrayref containing all the implementations for this interface.

    I think the callee has no business trying to second-guess the caller. The caller will have to decide which one it wants. I'm working on something similar (though we use 'registry' for what you call 'kernel', and 'service' for 'agent') and to me it seemed more natural that way.
Re: How to decide which implementation to use?
by valdez (Monsignor) on Mar 02, 2006 at 20:33 UTC

    This situation is explained in RFC 2616 Section 10.3.1, the final decision should be taken by the user (user agent probably).

    Ciao, Valerio

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://532672]
Approved by GrandFather
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (3)
As of 2020-11-29 19:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?