3 ms·
"Calling its methods in the desired order" This is my point. The order of calling the methods matters, because it manipulates opaque internal state. Since th
by nightski 6y ago
"Calling its methods in the desired order"
This is my point. The order of calling the methods matters, because it manipulates opaque internal state. Since this ordering matters, the caller is implicitly dependent on this internal state as it must know the order to call the methods in to get the desired result.
So it's very relevant to the outside world in my opinion and nothing is truly hidden. It becomes part of the public API whether you hide it or not.
- simiones 6y agoIt still depends. Think of a List class. Let's say it has methods to add, remove and retrieve elements, and it has a method to retrieve the size. Let's say the internal implementation is an array with a fill pointer. Obviously, before you can usefully call list.get(7), you must have called list.add(T) at least 7 times (assuming no deletes). Do you need to know the the state of the backing array and the value of the fill pointer? Do you need to know whether there even is a fill pointer, or a linked list underneath (obviously, the performance would be different so you would need to know at some point)?