Skip to content
This repository has been archived by the owner on Oct 23, 2023. It is now read-only.

Code organization #2

Closed
wants to merge 2 commits into from
Closed

Code organization #2

wants to merge 2 commits into from

Conversation

pedro-ww
Copy link

1.) Generalized the Protocol Conformance rule for all classes instead of just models.

2.) Removed confusing paragraph about replicating extensions.

3.) Added a rule to help standardize the layout of UIViews and UIViewControllers.

@pedro-ww pedro-ww changed the title Pperes/code organization Code organization May 11, 2017
@pedro-ww pedro-ww requested a review from prnewman May 11, 2017 22:35
@@ -209,9 +209,56 @@ class MyViewController: UIViewController, UITableViewDataSource, UIScrollViewDel
}
```

Since the compiler does not allow you to re-declare protocol conformance in a derived class, it is not always required to replicate the extension groups of the base class. This is especially true if the derived class is a terminal class and a small number of methods are being overridden. When to preserve the extension groups is left to the discretion of the author.
For UIKit views and controllers, besides separating protocol methods into their own extesion, also separate your class into section using `// MARK: -` to group lifecycle methods, setup methods, and action methods.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comments

Where possible, separate your classes into sections using // MARK: - comments to group lifecycle methods, setup methods, and action methods. Like TODO: and FIXME:, MARK: comments appear in the Xcode source navigator.

// setup Refresh Controller
}

// MARK: - Action

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Button actions


}

// MARK: - UITableView DataSource and Delegate

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

UITableViewDataSource and UITableViewDelegate methods

// table view data source methods
}

// MARK: - UIScrollViewDelegate

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

UIScrollViewDelegate methods

// init code here..
}

// MARK: - Life Cycle

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

UI Lifecycle

@pedro-ww pedro-ww closed this Sep 25, 2017
@pedro-ww pedro-ww deleted the pperes/code_organization branch September 25, 2017 22:23
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants