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

Simplification, Clarification, Robotification #118

Merged
merged 24 commits into from
Jun 5, 2018
Merged

Simplification, Clarification, Robotification #118

merged 24 commits into from
Jun 5, 2018

Conversation

designatednerd
Copy link
Contributor

Per discussion yesterday, I took a swing through the Handbook to see what could be updated and simplified.

In this PR, I:

  • Broke out the Style Guide from the Best Practices. Basically, now the style guide contains requirements, and best practices are strong suggestions and links to things that you should or should not do based on other people's experience.
  • Added a default .swiftlint.yml file that should be usable across most projects immediately.
  • Condensed a couple of files which had been separate into other sections.
  • Made a number of points significantly more concise.
  • Removed a couple of things which a) Were overly prescriptive and/or b) Were not actually being followed.
  • Made an "Archive" folder and added a couple of files that hadn't been updated in over a year.

Feedback requested:

  • Is there anything in Style Guide that should be in Best Practices, or vice versa?
  • Is there anything you feel we're enforcing too aggressively with SwiftLint?
  • Is there anything you feel we should be enforcing too leniently with SwiftLint?
  • Is there anything here you feel was taken out too hastily?

Any other feedback is most welcome!

COMMUNICATION.md Outdated
It good practice to elaborate. It may seem inefficient to be so verbose in our replies, but it will avoid misunderstandings, which can result in way greater inefficiency.
When you write a reply of less than ~5 words, have an alarm bell in the back of your head 🔔. Is it just tacit agreement? Then it’s probably fine! “Great job”, “Couldn’t have put it better”, “totes awesome!” are all fine.

In every other case though: 🚨! It good practice to elaborate. It may seem inefficient to be so verbose in our replies, but it will avoid misunderstandings, which can result in far greater inefficiency.
Copy link
Contributor

Choose a reason for hiding this comment

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

It's, missed a verb :)

COMMUNICATION.md Outdated

- **I see you are using an optional as an array of User object in the example above**, have you considered to have that property default to an empty array?
Copy link
Contributor

Choose a reason for hiding this comment

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

to have -> having :)

COMMUNICATION.md Outdated
@@ -1,51 +1,55 @@
# Communicating within the iOS team
# Communicating With Your Colleagues

Choose a reason for hiding this comment

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

I find this http://titlecase.com/ to be handy, so we should not uppercase unimportant words. What do you think @designatednerd ?

Copy link
Contributor

Choose a reason for hiding this comment

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

I'd avoid "title case" altogether, and just use good ol' regular spelling rules. First word of the sentence and proper nouns only. 😀

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah I think I did this a bit automatically as this is how I'm used to setting up titles in markdown documents. Will update.

@@ -4,20 +4,13 @@ These conventions apply to our open-source, internal, and client projects.

## Commits

The `master` branch is the stable branch. It's also used for development
purposes, as to avoid having `dev`, `development`, `staging`, `wip` and others.
The `master` branch is the stable branch. It's also used for development purposes, as to avoid having `dev`, `development`, `staging`, `wip` and others.

Choose a reason for hiding this comment

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

👍

STYLE_GUIDE.md Outdated
@@ -0,0 +1,383 @@
# Swift Style Guide
Copy link
Contributor

Choose a reason for hiding this comment

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

Did you add this whole thing, or did you just extract it from somewhere else? I wonder if there's any changes made to this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I extracted it and condensed it from Best Practices. There are definitely changes made to it to try and make it more concise and closer to enforcing what we're already doing.

- [ ] Send a tweet to [@maniacdev](https://twitter.com/maniacdev)
- [ ] Send a tweet to [@daveverwer](https://twitter.com/daveverwer) and [@iOSDevWeekly](https://twitter.com/iOSDevWeekly)
- [ ] Send a tweet to [@iOSGoodies](https://twitter.com/iOSGoodies) with the link to your PR
- [ ] Send a tweet to [@NatashaTheRobot](https://twitter.com/NatashaTheRobot)
Copy link
Contributor

Choose a reason for hiding this comment

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

😭 But yeah, she quit :(

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So did Maniac Dev - they haven't posted anything since late last year, even on their twitter.

Copy link
Contributor

@roberthein roberthein left a comment

Choose a reason for hiding this comment

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

I think this is a great improvement, very well written too. 👌

COMMUNICATION.md Outdated
@@ -1,51 +1,62 @@
# Communicating within the iOS team
# Communicating with your colleaugues
Copy link
Contributor

Choose a reason for hiding this comment

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

One "u" too many. ;)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

🤦‍♀️


In every other case though: 🚨! It's good practice to elaborate. It may seem inefficient to be so verbose in our replies, but it will avoid misunderstandings, which can result in far greater inefficiency.

## Criticizing or asking questions
Copy link
Contributor

Choose a reason for hiding this comment

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

👀 what happened here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

🇺🇸 spelling to be internally consistent with everything I was rewriting

Copy link
Contributor

@marijnschilling marijnschilling left a comment

Choose a reason for hiding this comment

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

Thanks for picking this up Ellen. I think it's great when we all agree what is in here 🙏

i left some comments about what could be clearer. But there's nothing in here that i disagree with!

I would like it though if we could add a rule about always giving a description or screenshot/gif with a PR. I think it saves valuable time for the reviewer if the requester makes clear what they worked on, how obvious it might seem to them! (the thing is the more obvious it is the easier it is to make a description, so everybody wins)

But i think we have this in danger, but i don't always see this giving a warning when there's no description 🤔 Or is it disabled?

- override_in_extension # Extensions shouldn't override declarations.
- private_action # IBActions should be private.
- private_outlet # IBOutlets should be private to avoid leaking UIKit to higher layers.
- private_unit_test # Unit tests marked private are silently skipped.
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this rule make sure we cannot mark tests as private because they are silently skipped when they are? Maybe clearer to word it like Unit tests should not be marked private because they are silently skipped

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You are correct. And I copy pasted this description from the list of SwiftLint rules, but I'll update it.

- prohibited_super_call # Some methods should not call super
- redundant_nil_coalescing # nil coalescing operator is only evaluated if the lhs is nil, coalescing operator with nil as rhs is redundant
- switch_case_on_newline # Cases inside a switch should always be on a newline
trailing_whitespace:
Copy link
Contributor

Choose a reason for hiding this comment

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

So this is giving you a warning when you add a whitespace at the end of a line, but skips empty lines?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

correct

Copy link
Contributor

@elland elland left a comment

Choose a reason for hiding this comment

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

Thanks for taking the time to do such a major rewrite. Did a first pass read, left some comments about grammar/spelling and asked for clarification on some topics. 👍

- If it's a static UI, a screenshot would do.
- If it's an interaction, a gif would help a lot. A good tool to make gifs is [Licecap](http://www.cockos.com/licecap/).
- If it's a static UI, a screenshot will do.
- If it's an interaction, a `gif` would help a lot. Goods tool to make `gif`s include [Licecap](http://www.cockos.com/licecap/), [GIPHY Capture](https://itunes.apple.com/us/app/giphy-capture-the-gif-maker/id668208984?mt=12), and [GIF Brewery](http://gifbrewery.com/).
Copy link
Contributor

Choose a reason for hiding this comment

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

Goods tool, Good tools? 😅

Copy link
Contributor Author

Choose a reason for hiding this comment

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

🤦‍♀️


After you have merged, you should delete the branch and smile. The smile is critical
part of the process, so don't forget this.
After you have merged, you should delete the branch and smile. The smile is critical part of the process, so don't forget this.
Copy link
Contributor

Choose a reason for hiding this comment

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

…is _a_ critical part… 👍

@@ -1,23 +1,26 @@
![logo](https://raw.githubusercontent.com/bakkenbaeck/iOS-playbook/master/assets/logo-v1.png)

Don't forget to check out our favourite [suite of components and helper methods](http://github.com/usesweet), to avoid duplication of work reimplementing them yourself..
Don't forget to check out our favorite [suite of components and helper methods](http://github.com/usesweet) and the [other B&B iOS repos](https://github.com/bakkenbaeck?language=swift) to see if we've already built something to help with what you're trying to do.
Copy link
Contributor

Choose a reason for hiding this comment

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

Overcorrected favourite here? 👀

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I updated all the spelling to be en-US since I was doing most of the writing and editing and that's what I'm used to.

- [ ] Create a local folder with your project name and run `swiftplate` from there
- [ ] 👶 Author: Your own name
- [ ] 📫 Author email: [email protected]
- [ ] 🌍 GitHub URL: https://github.com/bakkenbaeck/<YOUR_PROJECT_NAME>
- [ ] 🏢 Organization Name: Bakken & Baeck
- [ ] 🏢 Organization Name: Bakken & Bæck
Copy link
Contributor

Choose a reason for hiding this comment

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

👌🏽

Before shipping your component make sure that the README states what makes your Pod different than the other ones, been made by you might not be enough. It's very important that your README is :star2: fabulous :star2:.
- [ ] Make sure that the README states what makes this component different than the other ones - simply having been made by us is probably not enough. It's very important that your README is 🌟 fabulous 🌟.
- [ ] Provide a super-simple example on how to get the component up and running.
- [ ] If the component is dependent on other frameworks, explain why they're needed them and what they do. Don't assume that people know everything.
Copy link
Contributor

Choose a reason for hiding this comment

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

why they're needed them that doesn't sound right 😅

Copy link
Contributor Author

Choose a reason for hiding this comment

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

no it does not

STYLE_GUIDE.md Outdated

Images should be named consistently within an app to preserve organization and developer sanity. It is strongly suggested to append the state name to images for non-default states.

Images should be named in either `camelCase` or `lower_snake_case` to facilitate code generation based on the image names. Pick one and stick to it per project.
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd add here something along the lines of avoid using hyphens as it messes up code completion.

- `ic_refresh` and `ic_refresh_selected` for a refresh icon and its selected state used in multiple places throughout an app
- `articleNavigationBar` and `articleNavigationBarSelected` for something used in one specific place.

### Localized strings
Copy link
Contributor

Choose a reason for hiding this comment

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

Localised 😁

Copy link
Contributor

Choose a reason for hiding this comment

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

There are a bunch of those s/s/z/ changes. I'd really appreciate if we could keep the spelling consistent across documents (🇬🇧). 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have tried to keep this consistent within the current repo. If there's something I missed, please let me know.


Any strings visible to the user must be localized using `NSLocalizedString` or something wrapping it. It is way, way easier to set up all strings like this from the beginning than to add this feature later.

Don't use the developer-language content of the string as the localized string's key, because if you do, you then have to update the copy in multiple places.
Copy link
Contributor

Choose a reason for hiding this comment

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

not sure I follow.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Basically if you have

NSLocalizedString("Something in English", "Title of some view controller")

Your Localizable.strings files will contain

Base.lproj:

/* Title of some view controller */
"Something in English" = "Something in English";

es.lproj

/* Title of some view controller */
"Something in English" = "Alguna cosa en español";

So if you wind up changing the key, you have to update not just the key at the point where you're wrapping it in NSLocalized string, but you also have to update it in the Localizable.strings in Base.lproj and es.lproj, times whatever number of languages you're supporting.

Otherwise, the localized string system will just return the updated key, so it'll return everywhere in English.

Copy link
Contributor

Choose a reason for hiding this comment

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

ok I get what you meant now 👍🏽


Don't use the developer-language content of the string as the localized string's key, because if you do, you then have to update the copy in multiple places.

Use `lower_snake_case` for localized string keys to both facilitate code generation and to make it extremely obvious when there is an untranslated user-facing string, since by default if a value does not exist for a key in `Localizable.strings`, the key itself is returned.
Copy link
Contributor

Choose a reason for hiding this comment

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

There should be a way to know the key is missing when compiling. 😭

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I wrote a test helper for this years ago https://github.com/designatednerd/DNSiOSLocalizationTestHelpers - it would certainly be nice to know at compile time though


## Linting

For code lint we use [SwiftLint](https://github.com/realm/SwiftLint). Our current `.swiftlint.yml` file is available [here](default.swiftlint.yml).
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this point to the local file? I'm not sure how markdown links inside github work.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes

@designatednerd
Copy link
Contributor Author

@elland Anything further you'd like me to address?

a fix? Well, if you find a bug in a previous release, you can just, checkout the tag,
fork it, fix it, deploy the new build, and finally, submit a PR to merge it with `master`
to the sound of Daft Punk.
You might be wondering: why only `master`? What if I have to rollback to apply a fix? Well, if you find a bug in a previous release, you can just, checkout the tag, fork it, fix it, deploy the new build, and finally, submit a PR to merge it with `master` to the sound of Daft Punk.

Commit messages are in the [imperative present tense](http://stackoverflow.com/questions/3580013/should-i-use-past-or-present-tense-in-git-commit-messages), and have no period at the end.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

note to self for tomorrow: remove this line


The physical files should be kept in sync with the Xcode project files in order to avoid file sprawl. Any Xcode groups created should be reflected by folders in the filesystem. Code should be grouped by type and feature for greater clarity.

Make sure to use an [app-template](https://github.com/bakkenbaeck/app-template) for consistency.
Copy link
Contributor

Choose a reason for hiding this comment

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

Are we going to use this? I haven't in a long time.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have not since I've been on the same project since I started. In the past I have found it extremely helpful to have an app template, especially for things like "Setting up a bunch of boilerplate related to CI"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We should evaluate whether the current template is up-to-date for what we need there.

Copy link
Contributor

Choose a reason for hiding this comment

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

That would make more sense. Actually, can't we build something that integrates with Xcode anymore? So we can start the template from the new project tab?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I fought with this at a prior job. However, I think that's more of an issue for that repo than for this one. I think we should still point to a common template here.

@csdodd
Copy link
Contributor

csdodd commented Jun 5, 2018

Great work Ellen. I'm gonna merge as there is some consensus here. If there are still disagreements I suggest they be taken in a separate PR. This is a big change and I'd rather merge it in now and amend later rather than letting the PR get stale.

@csdodd csdodd merged commit eb1add5 into master Jun 5, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants