开发者

use of public variable in Play! framework model

开发者 https://www.devze.com 2023-03-26 22:01 出处:网络
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 mal

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 ?

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号