• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

CMP, abstract methods & encapsulation

 
Marcos Urata
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello there,

This may be a stupid question, but can anyone explain to me WHY creating abstract getter / setters for the virtual persistent fields provides better encapsulation if the implementation of the getter / setter (the ones that are exposed on the component interface and you also implement on the bean class) just calls the abstract getter / setter method.

Thank you
Marcos
 
Peer Reynders
Bartender
Posts: 2968
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So that you can change the type, number, and nature of the (encapsulated) virtual fields in the future, without necessarily having to change the (exposed) component interface.

Typically that happens when you start storing fields that you used to derive (or calculate) - or when you find a way to derive (or calculate) a field and you no longer want to store it.
 
Marcos Urata
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you! You made it clear now!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic