use of public variable in Play! framework model
I came across Play! framework a few days ago.It is mentioned that public variable are used as instance variables in Model.All my life, I have been told that it was a dangerous practice..some other malicious entity may 开发者_JAVA百科come and modify the object state etc..I didn't see any further explanation about the encapsulation issue in Play docs..Is the usage a safe practice? On the web,I had come across people critisizing the lack of encapsulation in python also.
Can someone clarify the merits/demerits..I would like to devote some time studying Play!..but I wish to know if any caveats exist.
regards
damon
Declaring the public properties allows play to enhance the class and makes the developer's life easy.
You can of course make the variables in private and provide your own getters and setters. Also, did you see the documentation here: http://www.playframework.org/documentation/1.2.2/model#properties ?
精彩评论