naming methods

Download Naming methods

Post on 07-Feb-2017

106 views

Category:

Technology

0 download

Embed Size (px)

TRANSCRIPT

  • Naming methods

  • Advanced Web Tech specialist

    Kwork Innovations

  • Differences in meaning

  • Method naming structures

  • Conventions

  • Microsoft Guidelines

  • Not all Microsoft Frameworks follow MS guideline

    .NET BCL (Base Class Library): String.Substring(), String.IndexOf()

    LINQ .First(), .Last().

    HTML Helper Html.EditorFor(), HTML.LabelFor(), HTML.ValidationSummary()

    Microsoft Guidelines

  • Common wisdom

  • Alternatives

  • Top verbs

    GetIsSetToCreateAddWriteFromReadCount

    TryHasCanFormatUpdateRemoveShowFindSendValidate

    ResolveCallMoveRegisterDeleteSerializeSelectLinkBindDrag

    FocusEditClearThrowStripProcessExecuteLockCopyCancel

    WaitApplyStoreSkipQueueCompareOrderCommitTransformReturn

    DownloadExpandSortLimitExportVerifyIncludeMakeRefreshExit

  • Option 1: To verb or not to verb

    GetLength() => Length() => Count()

    Single-verb is better than single-noun is better than verb+noun

    Transactional, I/O operation and state-change need a verb

    Email.HTML() => Email.SendHTML()

    Noun is better than long sentence for getting a value

    GetSquareRootOf => SquareRootOf()

  • Option 2: Always verb

    GetLength() => Count()

    Specific verb is better than verb+noun

    Always use a verb

    Email.HTML() => Email.SendHTML()

  • Microsoft Framework Design guidelines: General naming conventions

  • Capitalization Conventions

  • Word Choice

  • Using Abbreviations and Acronyms

  • Avoiding Language-Specific Names

  • Avoiding Language-Specific Names

  • Naming New Versions of Existing APIs

  • Naming API methods

  • REST vs. SOAP

  • http://www.example.com/customershttp://www.example.com/customers/33245

    http://www.example.com/products/66432http://www.example.com/customers/33245/orders

    REST Representation state transfer

    http://www.example.com/customershttp://www.example.com/customers/33245http://www.example.com/products/66432http://www.example.com/customers/33245/orders

  • SOAP Simple Object Access Protocol