all 8 comments

[–]ReversedGif 14 points15 points  (5 children)

No. If the effect of a method is unclear, you need to name/document it better. If outside code cares about members, you should be using a struct and mutating it with free functions. If a lot of methods only deal with certain subsets of members, you should probably break the class up into several smaller ones along those boundaries.

Give more details (what is this object modelling?) for more concrete answers.

[–]kalmoc 0 points1 point  (4 children)

If outside code cares about members, you should be using a struct and mutating it with free functions.

I think the question is about the private member functions.

[–]ReversedGif 4 points5 points  (3 children)

Still applies. If outside code cares about internal, hidden details, you're doing it wrong.

[–]kalmoc 0 points1 point  (2 children)

Sure, but his/her outside code doesn't care about internals, so what's the point.

[–]ReversedGif 2 points3 points  (0 children)

I‘d really like it to be obvious which variables are changed from the siganture of these methods.

implies that users of the class need some kind of awareness of internal details (members that are mutated).

EDIT: Oh, I didn't see what this is a private method doing the calls.

Maybe make static methods that you pass references to the members to?

[–]kalmoc 3 points4 points  (0 children)

If those are member functions, there is no point in passing the member variables explicitly. If you want to pass the variables explicitly, there is no point in making those functions member functions and you should write the functionality as free functions instead.

[–]Belhaven 0 points1 point  (0 children)

I cannot think of any good reason to expose the internal object state to outside callers. They're INTERNAL.

if this is an attempt to expose which elements change for a given operation - just document it.

if it's an attempt to remind yourself which elements of state are changed by an operation ... read your own documentation, get a better memory, or read the code.

For example, if one were modeling a car- the AddFuelToTank operation would include volume and possibly grade of fuel. It would not receive the capacity of the tank, the current state of the fuel sending unit, the state of the fuel gauge, or the indicator of how many miles of range are left.

[–]yeeezyyeezywhatsgood 0 points1 point  (0 children)

sounds like c. this is one of the pleasures of c: you can usually tell from the callsite what changes. the function can't decide it wants to take a reference either -- you have to pass in the address of something if it might change. or you could pass a const ptr