简体   繁体   English

在项目结构中何处放置特定于视图的逻辑?

[英]Where to place view specific logic in a project structure?

I'm adding some code to my project that allows drag and drop. 我在我的项目中添加了一些允许拖放的代码。

The Form used for the actual dropping is obviously part of the view/presentation layer. 用于实际删除的Form显然是视图/表示层的一部分。 However, there's a question mark on a TransferHandler class that contains the actual logic which detects and validates objects dropped on the window. 但是, TransferHandler类上有一个问号,其中包含检测和验证放置在窗口上的对象的实际逻辑。

Considering I have presentation, logic and data layers, where could this class be placed in the structure? 考虑到我具有表示层,逻辑层和数据层,可以将此类放置在结构中的什么位置?

If it is totally related to presentation layer, then at presentation layer. 如果它与表示层完全相关,则在表示层。

or if the same thing is needed when your presentation changes than at logic (service) layer. 或者当您的演示文稿更改时比逻辑(服务)层需要相同的内容时。

我建议使用一个表示层,但要创建一些包,例如util ,它将包含您用来帮助查看功能的所有类,例如drag-adnd-drop。

Which class is the information expert, meaning the class with the most information pertaining to the operation? 信息专家属于哪一类,即与操作有关的信息最多的一类? It seems like the presentation layer contains the class that is the information expert, thus it would be reasonable to place the code there. 表示层似乎包含作为信息专家的类,因此将代码放置在此处是合理的。 Should this action affect domain objects though you may want to look at implementing a use case controller which would be called from the presentation layer. 该操作是否应该影响域对象,尽管您可能希望考虑实现一个用例控制器,该用例控制器将从表示层调用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM