Clean-Swift / CleanStore

A sample iOS app built using the Clean Swift architecture. Clean Swift is Uncle Bob's Clean Architecture applied to iOS and Mac projects. CleanStore demonstrates Clean Swift by implementing the create order use case described by in Uncle Bob's talks.
https://clean-swift.com/clean-swift-ios-architecture/
MIT License
1.91k stars 315 forks source link

Same interface #6

Open onmyway133 opened 8 years ago

onmyway133 commented 8 years ago

I see that there are same methods in the 2 protocols

ViewControllerInput == PresenterOutput
PresenterInput == InteractorOutput
InteractorInput == ViewControllerInput

for example

protocol CreateOrderViewControllerOutput
{
  var shippingMethods: [String] { get }
  func formatExpirationDate(request: CreateOrder_FormatExpirationDate_Request)
}
protocol CreateOrderInteractorInput
{
  var shippingMethods: [String] { get }
  func formatExpirationDate(request: CreateOrder_FormatExpirationDate_Request)
}

Can we remove the Input protocol? If Interactor wants to be ViewController 's output, it needs to conform to ViewControllerOutput. This a little coupled is no harm because they are in the same module/component

How do you think ?

ehlersd commented 8 years ago

While on a technical case they are the same, I agree with the duplication and decoupling of these. I think of it a lot along the lines of double-entry bookkeeping....it helps to keep everything in-check, decoupled and isolated. In my experience, it also improves reusability and makes it somewhat easier when it comes to writing unit tests.

I'm currently using this process on a large Obj-C app, which currently has 27 scenes (will probably end up with about 60 scenes) and 19 different "workers". There are a lot of steps in this process that could be optimized out, but I found them to be valuable in keeping the app "clean" and wouldn't recommend any such consolidation (in my experience).

beseder42 commented 8 years ago

This question is very interesting and did not get yet the positive site of having Input and Output protocols. Could someone explain a bit more the positive effects of it?

alessioarsuffi commented 6 years ago

templates have been updated, check it out, now there isn't anymore that duplication of protocols :)

onmyway133 commented 6 years ago

@rayvinly ping ping 😛