Skip to main content
14 events
when toggle format what by license comment
Feb 27, 2019 at 15:55 comment added Laiv In which sense is the linked question related to the one here? Having logic within a getter is different than granting everybody with access to the getter.
Feb 27, 2019 at 15:55 comment added Laiv In which sense is the linked question related to the one here? Having logic within a getter is different than granting everybody with access to the getter.
Feb 27, 2019 at 15:09 vote accept Tlaloc-ES
Feb 27, 2019 at 14:40 comment added Tlaloc-ES maybe, but in my idea, you need put logic in get and set in some cases for example, in an order list, you put data in and list and you are sort after, and IMHO you do this in the set for that you can forget call the two methods, of course I want read your oppinion about that, An example about that is correctly in some cases stackoverflow.com/questions/2923116/…
Feb 27, 2019 at 14:32 comment added Tomasz Maciejewski @Tlaloc-ES If you put logic in get or set for class fields then you have bigger problems than one from your question.
Feb 27, 2019 at 14:28 comment added Laiv Are you familiar with the axioms of the OOP? Encapsulation, high cohesion, loose coupling? Also with the so popular SOLID principles? You will find the answer to the question in these principles and axioms.
Feb 27, 2019 at 14:25 comment added Laiv Then, the answer is "no", "it's not always better". If you consider OOP principles like encapsulation to be anything good.
Feb 27, 2019 at 14:24 comment added Tlaloc-ES @kadiii Yes this is more natural, but if the parameter need some of logic in the set or in the get for example? If you put it all logic in the get or in the set you can forgot the problems and get variable in any place
Feb 27, 2019 at 14:22 comment added Tlaloc-ES @Laiv I am talking in general, for example, and android project with models for get data from the api and ViewModels with MutableLiveData as an attribute, or a game with models for players and objects.
Feb 27, 2019 at 14:19 answer added Aganju timeline score: 6
Feb 27, 2019 at 14:18 comment added Laiv It depends. There's nothing that "always" is "better" no matter what in software engineering. Are we talking about plain objects (POJOs, POCOS, Mappers, etc)? Are we talking about ANY possible object in any layer?
Feb 27, 2019 at 14:18 comment added Tomasz Maciejewski Do you mean only execution WITHIN the object? If so than using 'this' is imho more natural as you don't want to encapsulate object internals from other object internals?
Feb 27, 2019 at 14:04 history edited Tlaloc-ES CC BY-SA 4.0
edited title
Feb 27, 2019 at 13:44 history asked Tlaloc-ES CC BY-SA 4.0