[英]play framework 2 - static methods
I'm a java developper for some while. 我有一段时间是Java开发人员。 Recently I've started working with play framework (in java, not scala) and what I like about it the most, is the stateless application type.
最近,我开始使用play框架(在Java中而不是Scala中),而我最喜欢的是无状态应用程序类型。 The question I have right now is :
我现在的问题是:
It's not a dumb question. 这不是一个愚蠢的问题。 You could theoretically use all static methods but it is not a good coding practice.
从理论上讲,您可以使用所有静态方法,但这不是一个好的编码实践。 Instead you can use something like domain objects that you pass around your program.
相反,您可以使用在程序中传递的域对象之类的东西。 You can change the data in a domain object as it is passed around and it only exists for the life cycle of your current execution stack (that is of course unless you persist it).
您可以在域对象中传递数据时更改它,并且该数据仅在当前执行堆栈的生命周期中存在(当然,除非您坚持执行,否则就不存在)。
This will keep your program stateless and prevent you having to use all static methods. 这将使程序保持无状态,并避免必须使用所有静态方法。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.