Jump to content

  • Log In with Google      Sign In   
  • Create Account


#ActualCornstalks

Posted 15 May 2013 - 08:42 PM

Honestly I like returning pointers for most cases. Using the pointer you dont have to make a thousand function calls. Especially in parallel programming this is very useful when you want to avoid static variables. Sometimes its not a good idea, or not even possible depending on the use, but I believe this is a perfectly valid programming habit. IMO

You do realize that that method destroys your ability to enforce class invariants? And that it has no advantage over simply making your members public (and has the disadvantage of being clunky and a really non-obvious and non-idiomatic way of modifying an object)?And that this doesn't do anything to help avoid static variables (how is this even related to static variables?)?

 

There might be a few exceptional cases where it's a decent idea, but it should be just that, exceptional cases. If it's your preferred/common method... something is wrong.


#1Cornstalks

Posted 15 May 2013 - 08:40 PM

Honestly I like returning pointers for most cases. Using the pointer you dont have to make a thousand function calls. Especially in parallel programming this is very useful when you want to avoid static variables. Sometimes its not a good idea, or not even possible depending on the use, but I believe this is a perfectly valid programming habit. IMO

You do realize that that method destroys your ability to enforce class invariants? And that it has no advantage over simply making your members public (and has the disadvantage of being clunky and a really non-obvious and non-idiomatic way of modifying an object)?And that this doesn't do anything to help avoid static variables (how is this even related to static variables?)?


PARTNERS