Opinions: API wrapping, how close to original API should you stay?

Raf rafiq at dreamthought.com
Fri Oct 6 00:18:03 BST 2006

On Wed, 4 Oct 2006, Nik Clayton wrote:
> Assuming you were writing to this API, would you prefer to use:
>     $ml->get_optimistic_lock()
>     $ml->get_OptimisticLock()
>     $ml->getOptimisticLock()

I think that the only thing that matters is that you stick to a consistent
and meaningful style.

When writing similar wrapper API's, I tend to assume that someone familiar
with the underlying/native interface, 'may' have an idea of contract and
behaviour 'that this API should be "capable" of exposing.' This, however,
shouldn't become a constraint on my style of naming methods.  All of the
above options - even the unsightly second - succeed in conveying the
semantic meaning and do not drift too far from the underlying data.  Thus,
it's better, imho, to remain consistent with the style of your greater
code-base and allow those utilising your API to become familar with
its own style ( + its own quirk and documentation ).

Just my late night thoughts.


More information about the london.pm mailing list