Learn notes from the zero-starting Swift (day 56)--naming convention

Source: Internet
Author: User
Tags naming convention

Original articles, welcome reprint. Reprint Please specify: Dongsheng's Blog

The code is full of its own defined names, and it is important to take a well-qualified name.

There are many naming methods, but the more famous, widely accepted nomenclature is:

    • Hungarian naming, generally just named variables, the principle is: variable name = Type prefix + description, such as Bfoo represents a Boolean type variable, Pfoo represents a pointer type variable. Hungarian naming is still controversial, and several of the swift code codes do not use Hungarian nomenclature.
    • L hump naming (Camel-case), also known as camel nomenclature, refers to the use of mixed uppercase and lowercase letters to name. The hump name is divided into: small hump method and big hump method.

A) The small hump method is the first word is all lowercase, followed by the first letter of the word capitalization, such as: Myroomcount;

b) The big Hump method is the first word of the initial letter is also capitalized, such as: classroom.

Hump naming is the main naming method of Swift coding specification, the more named content is different, can choose small hump method or big hump method. The following categories illustrate:

    • To name classes, structs, enumerations, and protocols, the large hump method, such as Splitviewcontroller, should be used.
    • File name, using the big hump method, such as Blockoperation.swift.
    • Extension file, sometimes the extension is defined in a separate file, it is named "Original type name + extension" as the extension file name, such as Nsoperation+operations.swift.
    • Variables and attributes should be used with small hump methods, such as Studentnumber.
    • Constant, using the large hump method, such as Maxstudentnumber.
    • Enumeration members, similar to constants, using the large hump method, such as executionfailed.
    • Function and method should adopt small hump method, such as Balanceaccount, isbuttonpressed and so on.

Welcome to follow Dongsheng Sina Weibo @tony_ Dongsheng.
Learn about the latest technical articles, books, tutorials and information on the public platform of the smart Jie classroom
?
More Products iOS, Cocos, mobile design courses please pay attention to the official website of Chi Jie Classroom: http://www.zhijieketang.com
Luxgen Classroom Forum Website: http://51work6.com/forum.php

Learn notes from the zero-starting Swift (day 56)--naming convention

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.