Re:Ask HN: Why do you make class members private?
by robalni on Tuesday July 26, 2022 @03:34AM
(#32235428)
> But you forget (someone came by with cookies) to actually shrink the backing array and also to change "top".
Someone could come by with cookies while I'm writing a private function too. This is more of a reason for having a function for doing something. Is the reason to make those variables private then to tell the programmer that there is a function that changes them and that you have to look through all the functions of the class before you touch them to see if there is a function that does what you need?
Someone could come by with cookies while I'm writing a private function too. This is more of a reason for having a function for doing something. Is the reason to make those variables private then to tell the programmer that there is a function that changes them and that you have to look through all the functions of the class before you touch them to see if there is a function that does what you need?