Deciding between obj->func() and func(obj)

Posted by GSto on Programmers See other posts from Programmers or by GSto
Published on 2011-02-15T22:01:04Z Indexed on 2011/02/15 23:34 UTC
Read the original article Hit count: 260

Filed under:
|

I was thinking about this when I was starting to set up some code for a new project: are there any rules of thumb for when a method should be part of an object, and when it should be a stand alone function that takes an object as a parameter?

EDIT: as pointed out in a comment, this can depend on language. I was working in C++ when it came to mind, though I'm this is an issue across a number of languages (and would still love to see answers that pertain to them).

© Programmers or respective owner

Related posts about oop

Related posts about coding-style