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

Brethren,

finally I am getting on with the times and today I have started adding web services using SOAP and WSDL (btw, check out Pod::WSDL, it's great). Wherever I look, be it SOAP::Lite documentation or "Programming Web Services with Perl" by Ray and Kulchenko, published SOAP methods use camel case: ie getBooksByAuthor instead of Perl's recommended get_books_by_author.

My question is: which style should my SOAP methods follow? On one hand, there is Perl style guide. On the other hand, underscores in method names may throw off the consumers of the web services.

I am currently leaning towards using camel case because that seems to be the convention. Furthermore, the language in which web services are implemented does not matter and does not have to be apparent.

What do you think?

  - Dmitri.

Replies are listed 'Best First'.
Re: Style question: SOAP method naming.
by shmem (Chancellor) on Aug 22, 2006 at 22:27 UTC
    I think being consistent is best. I personally find it annoying to have both naming conventions mixed in code, if they are used in the same domain of usage. So, look at boundaries. I'd use underscore_style in private code, and (maybe) camelCaseStyle for things consumers of the web services may see. Where both of them overlap, maybe a s/((?<!^)[A-Z])/'_'.lc($1)/ge (and it's reverse) would be handy for method translation... ;-)

    --shmem

    _($_=" "x(1<<5)."?\n".q·/)Oo.  G°\        /
                                  /\_¯/(q    /
    ----------------------------  \__(m.====·.(_("always off the crowd"))."·
    ");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}
      I'd second this recommendation. Camel case is standard for web services, and I'd use it for all SOAP methods exposed to the user. I'd use underscore_style in your code, per Perl convention. As annoying as it may be to have both styles around, it will help distinguish what's exposed to the user and what's not, and will keep your external interface in line with what SOAP users expect, and your internal code in line with what Perl people expect.
Re: Style question: SOAP method naming.
by gellyfish (Monsignor) on Aug 23, 2006 at 08:05 UTC

    I would say that on the whole SOAP "method" names have tended to be in camelCase because that is the convention in the languages that some of the earliest published services were made in (e.g. Java .) Of course this only really matters if you are using "rpc/encoded" envelopes rather than "document/literal" but you probably want to consider what the toolkit is going to do with the method name in framing the response - if you go with the lower case underscore separated names you are likely to have a body payload with an element name of something like: my_perl_method_nameResponse which is the worst of both worlds and horrible IMO, however this is going to be of concern if people are examining the Envelope or the WSDL manually. Personally nowadays I would tend to think of web services in terms of the message-centric document/literal style rather than the method-centric (and therefore less implementation neutral) rpc/encoded in which case the design and naming issue becomes one of what is most appropriate for the XML documents that are being exchanged.

    /J\