Giter Club home page Giter Club logo

swift-guide's Introduction

Introduction

The Swift coding conventions guide documents many best practices for writing Swift. Guidance here comes from a combination of our collective practical experiences and documentation from Apple. This is meant to be a living document and all contents are perpetually open for debate and improvement. For details on how to contribute, see the contribution guidelines.

Resources

Table of Contents

Legal Notices

Microsoft and any contributors grant you a license to the Microsoft documentation and other content in this repository under the Creative Commons Attribution 4.0 International Public License, see the LICENSE file, and grant you a license to any code in the repository under the MIT License, see the LICENSE-CODE file.

Microsoft, Windows, Microsoft Azure and/or other Microsoft products and services referenced in the documentation may be either trademarks or registered trademarks of Microsoft in the United States and/or other countries. The licenses for this project do not grant you rights to use any Microsoft names, logos, or trademarks. Microsoft's general trademark guidelines can be found at http://go.microsoft.com/fwlink/?LinkID=254653.

Privacy information can be found at https://privacy.microsoft.com/en-us/

Microsoft and any contributors reserve all other rights, whether under their respective copyrights, patents, or trademarks, whether by implication, estoppel or otherwise.

swift-guide's People

Contributors

cy255 avatar dalemyers avatar dependabot[bot] avatar huwilkes avatar markavitale avatar microsoft-github-operations[bot] avatar microsoftopensource avatar nodes11 avatar saadnajmi 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

Watchers

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

swift-guide's Issues

Integrating the Outlook style guide

In Outlook for iOS, we have our own style guide for Swift which is much more fully fledged than this style guide. I believe we also have more lines of Swift than anyone else at Microsoft, and have already shared our style guide with numerous other teams. Based on that, I think it would be a massive win for Swift programmers at Microsoft (and anyone else using this style guide) to merge our one into here.

The problem is that our style guide doesn't follow the layout of this one and it would be quite an undertaking as far as I can tell to integrate it. This is what we have for now: https://msiosdocs.azurewebsites.net/source_code/style_guide/swift/

How can we effectively integrate the two style guides?

Edit: This isn't a new convention but there wasn't a "general issue" button.

No example of `fileprivate`

What convention is being referenced?

As mentioned in #9, we don't have a good example of the ``fileprivate` access modifier in use.

How do you propose this convention could be improved? Please provide rationale and examples if possible.

Add an example of where that is a good idea

File Organization isn't consistent with most Swift code out there

What convention is being referenced?

The ordering in a file suggests most "important" to least "important", where how important it is is proportional to its visibility. i.e. public is the most important and private is the least important. This gives an interesting example of a code like this (trimmed here):

public class House {

    // public functions
    public init {
    // ...
    }

    private var size: Int = 0

}

You can see that the instance variable is at the bottom of the definition.

How do you propose this convention could be improved? Please provide rationale and examples if possible.

This rule is overly broad and not particularly helpful. Convention across the last several decades of programming has us put instance variables at the top of the file usually. We should correct to allow for this at the very least.

I'd also argue that a small private helper method makes more sense to be located next to the public method that uses it, rather than at the other end of the file.

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.