2

I'm a java developper for some while. 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. The question I have right now is :

  • since play framework is stateless, can we use static methods everywhere (without having the risk that a user use some information of another user for instance ?) or the static methods in play is the same as static in a ordinary java application. The JVM server side keeps the same info as a classic web application ? It may be a dumb question but thanks for your answers.
4

1 に答える 1

1

ばかげた質問ではありません。理論的にはすべての静的メソッドを使用できますが、それは適切なコーディング方法ではありません。代わりに、プログラムで渡すドメイン オブジェクトのようなものを使用できます。ドメインオブジェクト内のデータは、渡されるときに変更でき、現在の実行スタックのライフサイクルの間だけ存在します (もちろん、永続化しない限り)。

これにより、プログラムがステートレスに保たれ、すべての静的メソッドを使用する必要がなくなります。

于 2013-06-30T20:42:23.057 に答える