Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MD-Usage #69

Open
wants to merge 28 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
92a7026
MD-Usage
aaronTredrea Jul 30, 2020
4f677bc
Update Core-Usage.md
aaronTredrea Jul 31, 2020
3458bf2
Update Core-Usage.md
aaronTredrea Jul 31, 2020
f4bbe85
Update Core-Usage.md
aaronTredrea Jul 31, 2020
c2f3181
Update Core-Usage.md
aaronTredrea Jul 31, 2020
3a4b3a0
Update Core-Usage.md
aaronTredrea Jul 31, 2020
4223708
Update Core-Usage.md
aaronTredrea Jul 31, 2020
1abee9b
Update Core-Usage.md
aaronTredrea Jul 31, 2020
6712780
Update Core-Usage.md
aaronTredrea Jul 31, 2020
2ba3677
Update Core-Usage.md
aaronTredrea Jul 31, 2020
d7b2de9
Update Core-Usage.md
aaronTredrea Jul 31, 2020
ae97e26
Update Core-Usage.md
aaronTredrea Jul 31, 2020
9f08142
Update Core-Usage.md
aaronTredrea Jul 31, 2020
66f98ff
Update Core-Usage.md
aaronTredrea Jul 31, 2020
18d193c
Update Core-Usage.md
aaronTredrea Jul 31, 2020
f4c7a37
Update Core-Usage.md
aaronTredrea Jul 31, 2020
99f05fa
Update Core-Usage.md
aaronTredrea Jul 31, 2020
20707ae
Update Core-Usage.md
aaronTredrea Jul 31, 2020
935b243
Update Core-Usage.md
aaronTredrea Jul 31, 2020
c9416b8
Update Core-Usage.md
aaronTredrea Jul 31, 2020
7d08221
Update Core-Usage.md
aaronTredrea Jul 31, 2020
08852f7
Update Core-Usage.md
aaronTredrea Jul 31, 2020
16e2bfe
Update Core-Usage.md
aaronTredrea Jul 31, 2020
2d10468
Update Core-Usage.md
aaronTredrea Jul 31, 2020
3d455c1
Update Core-Usage.md
aaronTredrea Jul 31, 2020
fa4df66
origin/MD-Usage
aaronTredrea Jul 31, 2020
62375cb
Merge branch 'MD-Usage' of github.com:stanwood/Stanwood_Core_iOS into…
aaronTredrea Jul 31, 2020
7794880
origin/MD-Usage
aaronTredrea Jul 31, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
146 changes: 146 additions & 0 deletions Core-Usage.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
#Stanwood Core
aaronTredrea marked this conversation as resolved.
Show resolved Hide resolved

##Project Organisations
aaronTredrea marked this conversation as resolved.
Show resolved Hide resolved
Each Xcode project should be set with the following group structure in that order. This is so all our projects are consistent. [Project Organisation](https://www.figma.com/proto/AO3XMoeps1Yjj7aia5HpmA/Untitled?node-id=31%3A107&scaling=min-zoom)

###Utilities
aaronTredrea marked this conversation as resolved.
Show resolved Hide resolved
Always check that StanwoodCore does not provide this for free. Extensions, Helpers
###Services
aaronTredrea marked this conversation as resolved.
Show resolved Hide resolved
Tracking, DFP, Networking(dataProvider), etc',
###Model
aaronTredrea marked this conversation as resolved.
Show resolved Hide resolved
Should contain `ModelCollection`, and `Model` types
###Views
aaronTredrea marked this conversation as resolved.
Show resolved Hide resolved
Should contain any global custom views used
###Modules
aaronTredrea marked this conversation as resolved.
Show resolved Hide resolved
Each module should be set as a sub-group and contains ModuleViewController, ModuleWireframe, ModulePresenter, ModuleActionable ,ModuleParamaterable, ModuleViewable, Module.storyboard, ModuleDataSource ,ModuleDelegate, ModuleCells
### Core
Should contain AppDelegate ,AppController, AppCoordinator, Paramaters, Actions, AppData
Supporting Files
###Supporting Files
aaronTredrea marked this conversation as resolved.
Show resolved Hide resolved
Plists, other assets etc.

##AppDelegate
aaronTredrea marked this conversation as resolved.
Show resolved Hide resolved
Avoid adding any code to this class - it should only ever implement the functionality required by the Apple framework, instantiating and holding an AppController reference and nothing more. [AppDelegate](https://www.figma.com/proto/AO3XMoeps1Yjj7aia5HpmA/Untitled?node-id=9%3A29&scaling=min-zoom)

##AppController
aaronTredrea marked this conversation as resolved.
Show resolved Hide resolved
TheAppControllerhas a reference to the root window. Use appController to implements any functionality on a global state, auth(), fetchConfigurations(), reachability()as an example. It implements eachactionable, presentable, and viewable protocol that is injected into each of the presenters. [AppController](https://www.figma.com/proto/AO3XMoeps1Yjj7aia5HpmA/Untitled?node-id=9%3A43&scaling=min-zoom)
aaronTredrea marked this conversation as resolved.
Show resolved Hide resolved

##AppData
aaronTredrea marked this conversation as resolved.
Show resolved Hide resolved
Use this class for all global data model. It should only hold data model. [AppData](https://www.figma.com/proto/AO3XMoeps1Yjj7aia5HpmA/Untitled?node-id=31%3A50&scaling=min-zoom)

##Coordinator
aaronTredrea marked this conversation as resolved.
Show resolved Hide resolved
The Coordinator controls what is displayed at all times. It creates wireframes, prepares and presents. [Coordinator](https://www.figma.com/proto/AO3XMoeps1Yjj7aia5HpmA/Untitled?node-id=31%3A58&scaling=min-zoom)

##Wireframe
aaronTredrea marked this conversation as resolved.
Show resolved Hide resolved
The wireframe is a struct in which all of the functions are static. It always consists of a makeViewController function which will return a subclass of UIViewControlleror aUINavigationController, and a prepare function, which will connect the view controller to all the other classes in the module.
aaronTredrea marked this conversation as resolved.
Show resolved Hide resolved

The make function encapsulates the loading of a storyboard and then the viewController in question. The prepare function should pass in any data to build the module and inject them into the classes and structs. The prepare function should inject an object that implements the appropriate...actionable,...paramaterable, and...viewableprotocol into the presenter. [Wireframe](https://www.figma.com/proto/AO3XMoeps1Yjj7aia5HpmA/Untitled?node-id=88%3A0&scaling=min-zoom)

```
struct CarsWireframe {
static func makeViewController() -> CarsViewController {
/// instantiate controller from code, storyboard or Xib
}

static func prepare(viewController: CarsViewController, with actionable: CarsActionabel, _ paramaterable: CarsParamaterable) -> CarsViewController {
/// all the code to connect the objects
}
}
```
##Presenter
aaronTredrea marked this conversation as resolved.
Show resolved Hide resolved
The presenter implements all the logic and processing needed to display information on the screen, leaving the viewController with the task of the purely UI-specific elements.

The presenter communicates back to Actions via an action object that implements the actionable protocol. The presenter communicates with the viewable object to display information on the screen. The presenter calls paramaterable via a parameter object to get all the view specific parameters. Each UI element that triggers a background process, must communicate via the presenter to invoke the call. It must keep a weak reference to the viewable object.

Since a `UITableView` or `UICollectionView` only keeps weak references to a data source and delegate, the presenter must have a strong reference for each of these classes.

When creating a new presenter call, it must conform to the Presentable protocol and defineactionable, viewable, and paramaterable. If the presenter is a sourceType based presenter, then it must also conform toSourceTypePresentable, which will define the dataSource and delegate. [Presenter](https://www.figma.com/proto/AO3XMoeps1Yjj7aia5HpmA/Untitled?node-id=2%3A10&scaling=min-zoom)

##Actionable protocol
aaronTredrea marked this conversation as resolved.
Show resolved Hide resolved
This defines a protocol for each module that contains the call back functions for each action on the screen. It may also initiate a request that in turn invokes for networking calls and background processes and passes the responses back to the presenter, and manages the feedback to the user. [Actionable](https://www.figma.com/proto/AO3XMoeps1Yjj7aia5HpmA/Untitled?node-id=9%3A23&scaling=min-zoom)
For example:

```
protocol CarsActionable {
func getCars(for order: Order) -> Cars
func makeOrder(with car: Car)
func present(_ order: Order)
}
extension Actions: CarsActionable {
func getCars(for order: Order) -> Cars {
/// Fetch cars
}

func makeOrder(with car: Car) {
/// Make an order
}

func present(_ order: Order) {
/// Call coordinator and present order
}
}
```
##Viewable protocol
aaronTredrea marked this conversation as resolved.
Show resolved Hide resolved
This defines a protocol for each UIViewController and communicates with the presenter to display information on the screen. [Viewable](https://www.figma.com/proto/AO3XMoeps1Yjj7aia5HpmA/Untitled?node-id=9%3A1&scaling=min-zoom)
```
protocol CarsViewable {
var collectionView: UICollectionView! { get set }
}

class CarsViewController: CarsViewable {

@IBOutlet weak var collectionView: UICollectionView!

override func viewDidLoad() {
super.viewDidLoad()
}
}
```
##Parameterable protocol
aaronTredrea marked this conversation as resolved.
Show resolved Hide resolved
This defines a protocol for each module that contains all the view parameters. [Parameterable](https://www.figma.com/proto/AO3XMoeps1Yjj7aia5HpmA/Untitled?node-id=9%3A25&scaling=min-zoom)

```
protocol CarsParamaterable {
var cars: Cars { get }
}

extension Paramaters: CarsParamaterable {
var cars: Cars {
return appData.cars
}
}
```
##ViewController
aaronTredrea marked this conversation as resolved.
Show resolved Hide resolved
It must keep a strong reference to the presenter. All events (including button actions) make call backs to the presenter. This class should contain the bare minimum of code that is needed for initialisation and styling. [ViewController](https://www.figma.com/proto/AO3XMoeps1Yjj7aia5HpmA/Untitled?node-id=2%3A3&scaling=min-zoom)

##DataSource, Delegate, ModelCollection, and Model
aaronTredrea marked this conversation as resolved.
Show resolved Hide resolved
This has now been migrated to [here](https://github.com/stanwood/SourceModel_iOS) and using a separate pod. You can also find links to some of the key items below

[Delegate](https://www.figma.com/proto/AO3XMoeps1Yjj7aia5HpmA/Untitled?node-id=55%3A38&scaling=min-zoom)

[ModelCollection](https://www.figma.com/proto/AO3XMoeps1Yjj7aia5HpmA/Untitled?node-id=51%3A47&scaling=min-zoom)

[Model](https://www.figma.com/proto/AO3XMoeps1Yjj7aia5HpmA/Untitled?node-id=55%3A18&scaling=min-zoom)

BLAH BLAH WAIT FOR REVIEW
##Configurations & Constants
aaronTredrea marked this conversation as resolved.
Show resolved Hide resolved
[Configurations & Constants](https://www.figma.com/proto/AO3XMoeps1Yjj7aia5HpmA/Untitled?node-id=31%3A107&scaling=min-zoom)

```
struct Configuration {

/// group dynamic lets into named structs
}

struct Constants {

/// group static lets into named structs
}
```
##Services
aaronTredrea marked this conversation as resolved.
Show resolved Hide resolved
Services should have a reference in Actions and report back topresenter. [Services](https://www.figma.com/proto/AO3XMoeps1Yjj7aia5HpmA/Untitled?node-id=31%3A107&scaling=min-zoom)

##Networking
aaronTredrea marked this conversation as resolved.
Show resolved Hide resolved
This layer is super basic and relies heavily on Moya. Its best to view the example project for a more in depth insight into how moya works.

In short, the network layer has one exposed function that returns an initialised result. We use Generics to infer the type and either turn the object or an error.

as a general rule, the only class to access this will be the `DataProvider` [Networking](https://www.figma.com/proto/AO3XMoeps1Yjj7aia5HpmA/Untitled?node-id=31%3A34&scaling=min-zoom)