Coder Social home page Coder Social logo

clean-swift / cleanstore Goto Github PK

View Code? Open in Web Editor NEW
1.9K 1.9K 317.0 189 KB

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.

Home Page: https://clean-swift.com/clean-swift-ios-architecture/

License: MIT License

Swift 100.00%

cleanstore's Introduction

CleanStore

IDE Language Platform Build Status License

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.

cleanstore's People

Contributors

rayvinly avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cleanstore's Issues

Same interface

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 ?

Expanding example - Delete user?

How would you use clean architecture to, lets say, delete a user from the list of users? Currently I am re-sending the list of users via presentFetchedUsers, but I would rather tell my view controller to delete a single row from the table.

struct ListOrders {
  struct DeleteUser {
    struct Request {
      let index: Int
    }
    struct Response {
      ???
    }
    struct ViewModel {
      ??
    }
  }
}

List with multiple sections

Ive been trying to work out VIP on a tableview controller with multiple sections.
Each sections are unrelated to one another ( example : a help section on the listOrder screen)

How would you go about this with VIP? Should I use multiple Interactors?

OC version

Why not make a version of Objective-C language, which can be helpful to further understanding of the VIPER architecture

Some parts like the router class is not swifty

A lot of this architecture seems very unswifty and seems designed for older languages. For example no good swift developer would use the clunky Router class instead of a simple extension of the view controller.

CoreData not working?

Hi Ray,

I am using your code as basis for my own and struggling here with CoreData. My CoreData DataStore class, has the very same init() method with everything you have in your CleanStore project and the AppDelegate has no references to CoreData. The init() method is invoked and throws no exception. I can query the DB, insert and update. No exceptions thrown. But, the data is not actually inserted in the DB.

Have you experienced that? Thanks

Why tested protocols are suffixed by Spy and not Mock ?

I try to understand the difference between Mock and Spy in Unit Test.
I found in CleanStore that every mock/spy is suffixed with Spy.
But in this article, it's explained that Spy are real objects whereas Mock, new test objects doing nothing :

The difference is that in mock, you are creating a complete mock or fake object while in spy, there is the real object and you just spying or stubbing specific methods of it.

An exemple of Mock in CleanStore :

class ListOrdersPresentationLogicSpy: ListOrdersPresentationLogic
  {
    // MARK: Method call expectations
    
    var presentFetchedOrdersCalled = false
    
    // MARK: Spied methods
    
    func presentFetchedOrders(response: ListOrders.FetchOrders.Response)
    {
      presentFetchedOrdersCalled = true
    }
  }

So should you rename ListOrdersPresentationLogicSpy to ListOrdersPresentationLogicMock, or did I misunderstood something ?

Container View Controller Data passing

Hi Raymond.
I use your Clean Swift architecture design in my app. Thats nice, but, i have a issue with data passing.

Passing data on NEXT scene its easy. But.
What i should use, to pass data FROM Container View (thats embedded with TableViewController) TO Parent View controller?
In another words, what i should use for transfer data from CHILDREN View controller to PARENT view Controller.

I must use router? Or interactor? I don't understand this. How to connect inputs of different view controllers in backward direction?

Thanks for reply.

Question: Should the data source of the router be an interactor or a presenter?

Let's consider a scenario: we've sent the model obtained in the interactor to the presenter to convert it into a presentable format. In the presenter, one element's index within this data was changed. Let's assume that this change is solely related to the presentation layer. (For example, within the "members" array, the presenter identified the current member and moved them to the first position).

After this stage, if the router uses the interactor as its data source, when a user selects an index, they might access the wrong index. In other words, if the user action triggers the router, and what the user clicked is provided by the presenter, shouldn't the router get the data from the presenter to ensure accessing the correct data?

Question: Worker best practise network+core data

I would like to ask what's the best practise (if any) in case we have a scene that's fetching something from the network and after that, we want to store these data locally (core data). In addition, if multiple scenes required to have the same (network->core data) can we have a universal (re-usable) worker(s)?
I read about multiple stores in the TDD approach https://clean-swift.com/clean-swift-tdd-part-3-worker/ as well as multiple workers under the same interacor, https://clean-swift.com/role-of-the-interactor-and-its-workers/ but I am a bit confused regarding what approach should follow here

Clean Swift vs VIPER?

Reading http://clean-swift.com/clean-swift-ios-architecture/

Remembering the VIP cycle will become very handy when you implement features and fix bugs. You’ll know exactly which file and method to look for.

I see that VIPER is like putting Presenter in the center of the module. The Presenter conforms to both ViewControllerOuput, InteractorOutput, ... it is like the mediator. Furthermore, it also manages the Router. I find the Presenter a bit ambitious

How did you come up with Clean Swift?

Clean Junk

hey..plz this code give me in objective c

Question on Usage : Reload TableView

Ray,

So I have two modules, each created using clean swift templates:
-ListNotes_____________
-CreateNotes__________

Both are under the same navController.

Situation:
after user creates a new note and core data is updated and the user hits the navBar BACK button he is directed back to the ListNotesVC. ListNotes data is a swift array of managedObjects. (yah, I know). At issue is the tabview for listNotes is not showing the insert.

Can you suggest a way to get the tableview to update, ideally without using NSFetchedResultsController, without polluting the clean architecture?

Thanx in Advance

Clean Swift Refactoring

Clean Swift를 적용하면서 원칙이 제대로 지켜지지 않은 부분을 수정하는 작업

  • ex) ViewController에서 datastore에 있는 값을 참조할 경우 interactor interface에 해당 변수를 추가하여 접근할 수 있도록 수정
  • 이외에 불필요하게 weak self가 들어간 부분, 접근 키워드 등이 제대로 설정되지 않은 부분을 리팩토링함.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.