5 ms·
C# and Python (for examples) don't use getters and setters, they use properties which provide the same interface as direct access variables when the need arises
by surye 9y ago
C# and Python (for examples) don't use getters and setters, they use properties which provide the same interface as direct access variables when the need arises for more complexity, client code doesn't need to know about it. Languages without this feature needs to make everything getter/setter if they don't want to break the API when something needs additional logic.
- fancy_pantser 9y agoPython does have properties, which work via decorators @property (which decorates a getter) and @foo.setter.
- typon 9y agoHe literally just said that
- TazeTSchnitzel 9y agoAnd indeed Go code has its fair share of (otherwise) unnecessary getters because of this.