清理建筑 - 罗伯特马丁 - 如何连接使用案例 [英] Clean Architecture - Robert Martin - How to connect use cases

查看:171
本文介绍了清理建筑 - 罗伯特马丁 - 如何连接使用案例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想实现由罗伯特·马丁所描述的清洁建筑
更具体地说,我使用 VIPER 这是清洁架构的IOS版本。

I'm trying to implement the Clean Architecture described by Robert Martin. More specifically I'm using VIPER which is an iOS version of Clean Architecture.

我的问题是:

用户开始盯着它与地方(销)地图。
如果他点击一个按钮,一个引脚被丢弃,被他带到另一个视图中创建(或编辑,如果它是一个点击的存在引脚)的地方(或取消)。
在此另一种观点,用户可以编辑的地方的信息,然后单击返回或完成(或编辑)。
如果他点击完成后,PlaceDetailsViewController将消息发送到了这个地方的信息PlaceDetails presenter和PlaceDetails presenter使用CreatePlaceInteractor创造的地方。这个交互器返回它是用来识别该地点的GUID。

The user starts looking at a map with places (pins) on it. If he clicks a button, a pin is dropped and he is taken to another view to create (or edit if it was a click to an existent pin) the place (or cancel). In this other view, the user can edit the place's information and then click "back" or "done" (or "edit"). If he clicks "done", the PlaceDetailsViewController sends a message to the PlaceDetailsPresenter with the place information and the PlaceDetailsPresenter uses the CreatePlaceInteractor to create the place. This interactor returns the GUID which is used to identify the place.

如果用户点击创建发生之前回来,他回来地图和图钉上升客场(因为它没有GUID,它是一个新的地方,消失)。
如果他在创建后点击后面,脚撑在那里(因为它应该有一个GUID)。

If the user clicks back before creating the place, he gets back to the map and the dropped pin goes up and away (since it has no GUID, it is a new place and goes away). If he clicks back after creating, the pin stays there (because it should have a GUID).

我应如何连接这一切,应该在哪里的地方信息(包括GUID)存储?
为了澄清一点点:

How should I connect all that and where should the place information (including GUID) be stored? To clarify a little bit more:


  1. 谁应该告知地图presenter该引脚保持那里或消失?
    难道是PlaceDetails presenter或者我应该将此信息传递给PlaceDetailsWireframe - > MapWireframe - >地图presenter? - >图形页面

  2. 之前回去,应该在哪里此GUID存储在PlaceDetails presenter或PlaceDetailsViewController?

现在这就是我有:

Right now that's what I have:

编辑:

基本上,我认为这个问题是VIPER罗伯特马丁的清洁架构来了,他来自一个Web(Rails)的背景,所以他并没有想太多状态(或者没有在他的谈话中指定它)。

Basically I think the problem is that VIPER came from Robert Martin's Clean Architecture and he comes from a Web (Rails) background, so he doesn't think much about state (or don't specify it in his talks).

这主要是我的问题,应该在哪里的状态进行存储,不同的模块应该如何沟通,它应该是通过线框,或通过数据库,或通过交互件,或通过presenters每个通信其他像这里 https://github.com/objcio/issue-13-viper-swift

Which is mainly my question, where should the state be stored, how should the different modules communicate, should it be through the Wireframe, or through the database, or through the interactors, or through the Presenters communicating with each other like here https://github.com/objcio/issue-13-viper-swift.

推荐答案

我不知道很多关于毒蛇,所以我不能有关评论。然而,该系统的总状态应在实体对象举行,由交互件操纵。 GUI的详细状态(选择矩形,等等)应该由控制器和presenter之间一个特殊的连接管理。

I don't know much about Viper, so I can't comment about that. However, the gross state of the system should be held in the entity objects and manipulated by the interactors. The detailed state of the GUI (selection rectangles, etc) should be managed by a special connection between the controller and the presenter.

在你的情况下,有两个屏幕。地图和地点的编辑。点击地图上导致调用要么placePinController。它收集点击的位置,任何其他上下文数据,构建一个placePinRequest数据结构,并把它传递给它检查销的位置PlacePinInteractor,验证,如果必要,创建一个地方实体来记录针,构造一个EditPlaceReponse对象,并把它传递给EditPlace presenter带来了在位编辑器屏幕。

In your case there are two screens. The map, and the place editor. Clicking on the map causes either the placePinController to be invoked. It gathers the location of the click, and any other contextual data, constructs a placePinRequest data structure and passes it to the PlacePinInteractor which checks the location of the pin, validates it if necessary, create a Place entity to record the pin, constructs a EditPlaceReponse object and passes it to the EditPlacePresenter which brings up the place editor screen.

如果完成按钮被点击的地方编辑屏幕上调用该编辑的数据收集成一个EditPlaceRequest数据结构,并把它传递给EditPlaceInteractor的EditPlaceController。等等。

If the Done button is clicked on the place editor screen it invokes the EditPlaceController which gathers up the edited data into an EditPlaceRequest data structure and passes it to the EditPlaceInteractor. etc..

您专门问了一下脚的GUID。这将通过将实体来创建和传递回editPlace presenter PlacePinInteractor。

You specifically asked about the GUID of the pin. That would be created by the Place entity and passed back to the editPlacePresenter PlacePinInteractor.

这篇关于清理建筑 - 罗伯特马丁 - 如何连接使用案例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆