Skip to main content
14 events
when toggle format what by license comment
Apr 12, 2017 at 7:31 history edited CommunityBot
replaced http://programmers.stackexchange.com/ with https://softwareengineering.stackexchange.com/
Feb 20, 2016 at 19:08 history tweeted twitter.com/StackProgrammer/status/701121152089985025
Feb 17, 2016 at 16:37 answer added Jerry Coffin timeline score: 5
Feb 17, 2016 at 15:25 comment added Robert Harvey Also, for what it's worth, I would consider writing a free-standing function that calls a member function on an object which modifies state a bad practice, unless any state changes are completely encapsulated in the free-standing function; i.e. the function is responsible for newing up and also disposing said object.
Feb 17, 2016 at 15:22 comment added Robert Harvey Then Scott's technique has solely to do with encouraging functional-style, effect-free programming. Not sure what const has to do with anything, but if you're that worried about this, you might want to ask Scott directly what he meant. Regardless, the importance of free-standing functions (and the role they play in simplifying and clarifying code) seems self-evident to me. You did ask the question, and what I'm telling you as a fellow programmer is that the "uniformity" you speak of is completely unimportant to me in the grand scheme of things.
Feb 17, 2016 at 15:07 comment added AlwaysLearning @RobertHarvey A free-standing function may very well call a public member function, which does modify state... For pure functions, you have const, which has nothing to do with our topic.
Feb 17, 2016 at 14:59 comment added Robert Harvey Most programmers nowadays use a modern IDE that already tells them this information anyway. The value from the separation is not so much knowing when you're calling a member function and possibly modifying state (which should already be obvious), but knowing that, in a free standing function, you can almost certainly not have to worry about side-effects occurring (i.e. modifying state). This enables an immutable, functional programming style that is quite powerful for things like concurrency. You won't have that capability if you have no idea if side-effects are occurring on function calls.
Feb 17, 2016 at 14:55 comment added AlwaysLearning @RobertHarvey Sure, but he has other things to keep in his head besides remembering which functions are called in which way. The time to look that up is expensive as well. Moreover, he does not get any additional value from the separation, does he?
Feb 17, 2016 at 14:53 comment added Robert Harvey Presumably the user is a programmer, if we're talking about classes and free-standing functions. If they user is programming in C++, he is almost certainly informed enough to use the functions properly, in their intended paradigm, and communicating their proper use by making them member or free-standing is just polite.
Feb 17, 2016 at 14:52 comment added AlwaysLearning @RobertHarvey Why does the user care about that separation? The author of the class cares, but he can always go to the class declaration to see the list of member functions...
Feb 17, 2016 at 14:50 comment added Robert Harvey No. Scott's technique clearly indicates the functions that access state from the functions that don't. Your wrapper functions would clobber that separation. The non-member functions enable encapsulation of state. The free-standing functions enable immutable, functional-style programming, a technique that is clearly communicated by their use. That the functions be all free standing or all not free standing in the quest for uniformity is completely unimportant.
Feb 17, 2016 at 14:48 history edited AlwaysLearning CC BY-SA 3.0
added 43 characters in body
Feb 17, 2016 at 14:42 review First posts
Feb 24, 2016 at 4:51
Feb 17, 2016 at 14:41 history asked AlwaysLearning CC BY-SA 3.0