And remember: if you code or use classes that only have setters and getters, you are not doing object-oriented development, and you probably shouldn't care about performance. These are called structures and are an integral part of structured procedural programming around the end of the 1980s.
Objects, as a rule, do not have one or very few setters and neither one nor a very small number of getters. Most methods will perform the actual functionality associated with the class in which they are located. To visualize the difference, consider a bean with 10 setters and an object that has a load () method. One encourages encapsulation and therefore will be more understandable and easier to maintain - the other hangs on a street corner and can and is used by anyone, anywhere.
OPTIONAL: for those of you who argue with this because you read somewhere that the presence of functionality in your entities is bad, then I propose this simple solution - to wrap (not copy) an instance of an object in a domain class. This combines code (domain class) with data (entity), so the whole is now a true object. Put all the functionality that works with entity data in the domain class - having done this, no other class should need shared access to the entity, so do not expose these elements and sets, only open the functionality.
Rodney P. Barbati Aug 28 '13 at 19:36 on 2013-08-28 19:36
source share