I have been programming in python and Java for quite a number of years and one thing I find myself doing is using the setters and getters from Java in Python but a number of blogs seem to think using the dot notation for access is the pythonic way.
What I would like to know is if using dot to access methods does not violate abstraction principle?
If for example I implement an attribute as a single object and use dot notation to access, if I wanted to change the code later so that the attribute is represented by a list of objects, that would require quite some heavy lifting which violates abstraction principle.
1
It depends :-). If you treat the . notation as a shortcut for a public getter, then personally I have no issue with that. However, having everything publicly accessible via the . notation by default in my opinion is a mistake. Not all fields should be automatically visible to the outside world.
1