Boost logo

Boost :

From: William Kempf (sirwillard_at_[hidden])
Date: 2000-08-17 13:41:33


--- In boost_at_[hidden], Gary Powell <Gary.Powell_at_s...> wrote:
> Another reason to use free functions vs member functions:
>
> o) It can reduce compile time dependencies, if you place the free
functions
> in a separate include file. Then things which require
> access to the object include only the definition.h and things which
> use the free functions include the objectUtility.h file.

There are ways to reduce compile time dependencies beyond just using
free functions. I don't see this as a real argument.

> --------------------------
> Regarding Jeremy's example if you don't own the interface/code to
> Joe::Vector or suzy::vector_add adding a member function is not an
option.
> i.e. Using third party software. If you go ahead and modify the
include
> files to joe's vector, whenever you get an update you are required
to repeat
> this modification. Ick!

Then wrap it instead. Jeremy's example fails to illustrate anything,
because template specialization could have been used instead. Or an
adapter class could have been used. All of these require a lot of
intimacy with suzy::vector_add, however, which calls into question
whether any of them should be employed or if we should simply start
from scratch here. I guess I still don't see any issue, or any
improvement by using free functions.
 
> The fix by specialization takes care of this. (Also it can be used
to
> generate a "size" function if none exists at all in Joe::vector)

Good luck adding a "size" function if none exists in Joe::vector,
since such a method would require access to state information that
shouldn't be directly exposed in the class any way.
 
> The issue is a that a class should provide no more member functions
than are
> necessary. Just what that minimum set is of course open to
discussion and
> endless debate.

Now this I will agree with. However, it does not lead to "prefer
free functions over member functions" in my mind.

Bill


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk