in reply to module w/ object-oriented and functional interfaces: best practices?
Separate the methods from the procedures into different packages. I'll usually end up with the procedures being tiny wrappers around methods.
I've done the "detect if you are being called like a method or not" dance before. In hindsight, I just don't find it worth it in the long run. I always end up being burned by the relative ambiguity (calling things the wrong way or writing something new the wrong way or having to go with awkward new interfaces in order to prevent obviously unacceptable amounts of ambiguity).
Having a tiny set of wrappers in a separate package makes the situation very clear and prevents boilerplate being pasted into the top of each method-as-desert-topping-and-floor-wax sub.
- tye
|
|---|