Jump to content

Wikipedia:Sandbox

From Wikipedia, the free encyclopedia

This is an old revision of this page, as edited by 5.41.95.112 (talk) at 19:20, 4 May 2018. The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

CamelCaseIsNamedAfterThe "humps"OfItsCapitalLetters,SimilarToTheHumpsOfA BactrianCamel.

CamelCase (stylizedAs camelCaseOr CamelCase;AlsoKnownAs camelCapsOrMoreFormallyAs medialCapitals)IsThePracticeOfWritingCompoundWordsOrPhrasesSuchThatEachWordOrAbbreviationInTheMiddleOfThePhraseBeginsWithA capitalLetter,WithNoInterveningSpacesOrPunctuation.CommonExamplesInclude "iPhone", "eBay", "FedEx", "DreamWorks",And "HarperCollins".ItIsAlsoSometimesUsedInOnlineUsernamesSuchAs "JohnSmith",AndToMakeMulti-word domainNamesMoreLegible,ForExampleInAdvertisements.

SomeSystemsPreferCamelcaseWithTheFirstLetterCapitalised,OthersNot.[1]<refName=nfrmwk>Template:CiteWeb</ref>[2]ForClarity,ThisArticleCallsTheTwoAlternatives upperCamelCase (initialUpperCaseLetter,AlsoKnownAs PascalCase)And lowerCamelCase (initialLowerCaseLetter).SomePeopleAndOrganizations,Notably Microsoft,<refName=nfrmwk/>UseTheTerm camelCaseOnlyForLowerCamelCase. PascalCaseMeansOnlyUpperCamelCase.

CamelCaseIsDistinctFrom TitleCase,WhichCapitalisesAllWordsButRetainsTheSpacesBetweenThem,AndFrom TallManLettering,WhichUsesCapitalsToEmphasizeTheDifferencesBetweenSimilar-lookingWordsSuchAs "predniSONE"And "predniSOLONE".

TheName "CamelCase"IsNotRelatedToThe "CamelBook",ThePopularNicknameOfTheBook ProgrammingPerlDueToThePictureOfACamelOnItsCover,WhichUsesAll-lowercaseIdentifiersWith underscores (sometimesCalled snakeCase)InItsSampleCode.

VariationsAndSynonyms

TheOriginalNameOfThePractice,UsedIn mediaStudies, grammarsAndThe OxfordEnglishDictionary,Was "medialCapitals".OtherNamesSuchAs "InterCaps"Or "CamelCase"AreRelativelyRecentAndMoreCommonInComputer-relatedCommunities.OtherSynonymsInclude:

TheEarliestKnownOccurrenceOfTheTerm "InterCaps"OnUsenetIsInAnApril 1990PostToTheGroup alt.folklore.computersByAviRappoport.<refName="compoundNames" />TheEarliestUseOfTheName "CamelCase"OccursIn 1995,InAPostByNewtonLove.[12]LoveHasSinceSaid, "WithTheAdventOfProgrammingLanguagesHavingTheseSortsOfConstructs,TheHumpinessOfTheStyleMadeMeCallItHumpyCaseAtFirst,BeforeISettledOnCamelCase.IHadBeenCallingItCamelCaseForYears. ...TheCitationAboveWasJustTheFirstTimeIHadUsedTheNameOnUSENET."[13]

TraditionalUseInNaturalLanguage

InWordCombinations

TheUseOfMedialCapitalsAsAConventionInTheRegularSpellingOfEverydayTextsIsRare,ButIsUsedInSomeLanguagesAsASolutionToParticularProblemsWhichAriseWhenTwoWordsOrSegmentsAreCombined.

InItalian,PronounsCanBeSuffixedToVerbs,AndBecauseTheHonorificFormOfSecond-personPronounsIsCapitalized,ThisCanProduceASentenceLike nonHoTrovatoIlTempoDiRisponderLe ("IHaven'tFoundTimeToAnswerYou" -Where LeMeans "you").

In German,TheMedialCapitalLetter I,Called Binnen-I,IsSometimesUsedInAWordLike StudentInnen ("students")ToIndicateThatBoth Studenten ("maleStudents")And Studentinnen ("femaleStudents")AreIntendedSimultaneously.However,Mid-wordCapitalisationDoesNotConformTo GermanOrthography;ThePreviousExampleCouldBeCorrectlyWrittenUsing parenthesesAs Student(inn)en,AnalogousTo "congress(wo)man"InEnglish.[14]

In Irish,CamelcaseIsUsedWhenAnInflectionalPrefixIsAttachedToAProperNoun,ForExample iNGaillimh ("in Galway"),From Gaillimh ("Galway"); anTAlbanach ("theScottishPerson"),From Albanach ("ScottishPerson");And goHÉirinn ("to Ireland"),From Éire ("Ireland").InRecent ScotsGaelicOrthography,AHyphenHasBeenInserted: anT-Albannach.

ThisConventionIsAlsoUsedBySeveralWritten BantuLanguages (e.g., kiSwahili, "SwahiliLanguage"; isiZulu, "ZuluLanguage")AndSeveralIndigenous languagesOfMexico (e.g. Nahuatl, Totonacan, Mixe–Zoque,AndSome Oto-MangueanLanguages).

In DutchTheLetter JIsCapitalizedIfItIsImmediatelyPrecededByACapital I,ForExampleInTheCountryname IJsland.

InEnglish,MedialCapitalsAreUsuallyOnlyFoundInScottishOrIrish "Mac-"Or "Mc-"Names,WhereForExample MacDonald,McDonald,And MacdonaldAreCommonSpellingVariantsOfTheSameName,AndInAnglo-Norman "Fitz-"Names,WhereForExampleBoth FitzGeraldAnd FitzgeraldAreFound.

InTheirEnglishStyleGuide TheKing'sEnglish,FirstPublishedIn 1906, H.W.And F.G.FowlerSuggestedThatMedialCapitalsCouldBeUsedInTriple compoundWordsWhere hyphensWouldCauseAmbiguity—theExamplesTheyGiveAre KingMark-like (asAgainst KingMark-like)And Anglo-SouthAmerican (asAgainst Anglo-SouthAmerican).However,TheyDescribedTheSystemAs "tooHopelesslyContraryToUseAtPresent."[15]

InTransliterations

InTheScholarlyTransliterationOfLanguagesWrittenInOtherScripts,MedialCapitalsAreUsedInSimilarSituations.ForExample,InTransliterated Hebrew, ha'<spanStyle="font-family:TimesNewRoman">IvriMeans "theHebrewPerson"Or "theJew"And b'YerushalayimMeans "inJerusalem". In TibetanProperNamesLike rLobsang,The "r"StandsForAPrefixGlyphInTheOriginalScriptThatFunctionsAs toneMarkerRatherThanANormalLetter.AnotherExampleIs ts<spanStyle="font-family:TimesNewRoman">Iurku,ALatinTranscriptionOfThe ChechenTermForTheCappingStoneOfTheCharacteristic MedievalDefensiveTowersOf ChecheniaAnd Ingushetia;TheCapitalLetter "<spanStyle="font-family:TimesNewRoman">I"HereDenotingA phonemeDistinctFromTheOneTranscribedAs "i".

InAbbreviations

MedialCapitalsAreTraditionallyUsedInAbbreviationsToReflectTheCapitalizationThatTheWordsWouldHaveWhenWrittenOutInFull,ForExampleInTheAcademicTitles PhDOr BSc.InGerman,TheNamesOfStatutesAreAbbreviatedUsingEmbeddedCapitals,E.g.StGB (Strafgesetzbuch)ForCriminalCode,PatG (Patentgesetz)ForPatentAct,BVerfG (Bundesverfassungsgericht)For FederalConstitutionalCourt,OrTheVeryCommonGmbH (GesellschaftMitBeschränkterHaftung)For CompanyWithLimitedLiability.InThisContext,ThereCanEvenBeThreeOrMore "CamelCase"Capitals,E.g.InTzBfGForTeilzeit-UndBefristungsgesetz (ActOnPart-TimeAndLimitedTermOccupations).InFrench,CamelCaseAcronymsSuchAs OuLiPo (1960)WereFavoredForATimeAsAlternativesToInitialisms.

CamelCaseIsOftenUsedToTransliterateInitialismsIntoAlphabetsWhereTwoLettersMayBeRequiredToRepresentASingleCharacterOfTheOriginalAlphabet,E.g., DShKFrom Cyrillic ДШК.

HistoryOfModernTechnicalUse

ChemicalFormulae

TheFirstSystematicAndWidespreadUseOfMedialCapitalsForTechnicalPurposesWasTheNotationForChemicalFormulaeInventedByTheSwedishChemist JacobBerzeliusIn 1813.ToReplaceTheMultitudeOfNamingAndSymbolConventionsUsedByChemistsUntilThatTime,HeProposedToIndicateEachChemicalElementByASymbolOfOneOrTwoLetters,TheFirstOneBeingCapitalized.TheCapitalizationAllowedFormulaeLike "NaCl"ToBeWrittenWithoutSpacesAndStillBeParsedWithoutAmbiguity.[16][17]

Berzelius'SystemContinuesToBeUsed,AugmentedWithThree-letterSymbolsSuchAs "Uue"ForUnconfirmedOrUnknownElementsAndAbbreviationsForSomeCommonSubstituents (especiallyInTheFieldOfOrganicChemistry,ForInstance "Et"For "ethyl-").ThisHasBeenFurtherExtendedToDescribeThe aminoAcidSequencesOf proteinsAndOtherSimilarDomains.

EarlyUseInTrademarks

SinceTheEarly 20thCentury,MedialCapitalsHaveOccasionallyBeenUsedFor corporateNamesAndProduct trademarks,SuchAs

ComputerProgramming

InThe 1970sAnd 1980s,MedialCapitalsWereAdoptedAsAStandardOrAlternative namingConventionForMulti-word identifiersInSeveral programmingLanguages.ThePreciseOriginOfTheConventionInComputerProgrammingHasNotYetBeenSettled.A 1954ConferenceProceedings[19]OccasionallyInformallyReferredToIBM's SpeedcodingSystemAs "SpeedCo". ChristopherStrachey'sPaperOn GPM (1965),[20]ShowsAProgramThatIncludesSomeMedialCapitalIdentifiers,Including "NextCh"And "WriteSymbol".

Multiple-wordDescriptiveIdentifiersWithEmbeddedSpacesSuchAs endOfFileOr charTableCannotBeUsedInMostProgrammingLanguagesBecauseTheSpacesBetweenTheWordsWouldBe parsedAs delimitersBetween tokens.TheAlternativeOfRunningTheWordsTogetherAsIn endoffileOr chartableIsDifficultToUnderstandAndPossiblyMisleading;ForExample, chartableIsAnEnglishWord (ableToBeCharted).

SomeEarlyProgrammingLanguages,Notably Lisp (1958)And COBOL (1959),AddressedThisProblemByAllowingA hyphen ("-")ToBeUsedBetweenWordsOfCompoundIdentifiers,AsIn "END-OF-FILE":LispBecauseItWorkedWellWithPrefixNotation (aLispParserWouldNotTreatAHyphenInTheMiddleOfASymbolAsASubtractionOperator)AndCOBOLBecauseItsOperatorsWereIndividualEnglishWords.ThisConventionRemainsInUseInTheseLanguages,AndIsAlsoCommonInProgramNamesEnteredOnA commandLine,AsInUnix.

However,ThisSolutionWasNotAdequateForMathematically-orientedLanguagesSuchAs FORTRAN (1955)And ALGOL (1958),WhichUsedTheHyphenAsAnInfixSubtractionOperator.TheseEarlyLanguagesInsteadAllowedIdentifiersToContainUnrestrictedEmbeddedSpaces,DeterminingTheEndOfTheIdentifierByContext.ThisApproachWasAbandonedInLaterLanguagesDueToTheComplexityItAddsTo tokenization. (FORTRANInitiallyRestrictedIdentifiersToNoMoreThanSixCharacters,EffectivelyPreventingMulti-wordIdentifiersExceptThoseMadeOfVeryShortWords,SuchAs "GOTO"="GOTO".)

ExacerbatingTheProblem,Common punchedCardCharacterSetsOfTheTimeWereUppercaseOnlyAndLackedOtherSpecialCharacters.ItWasOnlyInTheLate 1960sThatTheWidespreadAdoptionOfThe ASCIICharacterSetMadeBothLowerCaseAndThe underscoreCharacter _UniversallyAvailable.SomeLanguages,Notably C,PromptlyAdoptedUnderscoresAsWordSeparators,AndIdentifiersSuchAs end_of_fileAreStillPrevalentInCProgramsAndLibraries (asWellAsInLaterLanguagesInfluencedByC,SuchAs PerlAnd Python).However,SomeLanguagesAndProgrammersChoseToAvoidUnderscores—amongOtherReasonsToPreventConfusingThemWith whitespace—andAdoptedCamelCaseInstead.

CharlesSimonyi,WhoWorkedAt XeroxPARCInThe 1970sAndLaterOversawTheCreationOfMicrosoft'sOfficeSuiteOfApplications,InventedAndTaughtTheUseOf HungarianNotation,OneVersionOfWhichUsesTheLowerCaseLetter(s)AtTheStartOfA (capitalized)VariableNameToDenoteItsType.OneAccount[citation needed]ClaimsThatTheCamelCaseStyleFirstBecamePopularAtXeroxPARCAround 1978,WithThe MesaProgrammingLanguageDevelopedForThe XeroxAltoComputer.ThisMachineLackedAnUnderscoreKey,AndTheHyphenAndSpaceCharactersWereNotPermittedInIdentifiers,LeavingCamelCaseAsTheOnlyViableSchemeForReadableMultiwordNames.ThePARCMesaLanguageManual (1979)IncludedACodingStandardWithSpecificRulesForUpperAndLowerCamelCaseThatWasStrictlyFollowedByTheMesaLibrariesAndTheAltoOperatingSystem.

The SmalltalkLanguage,WhichWasDevelopedOriginallyOnTheAltoAndBecameQuitePopularInTheEarly 1980s,MayTemplate:AccordingToWhomHaveBeenInstrumentalInSpreadingTheStyleOutsidePARC.CamelCaseWasAlsoUsedByConventionForManyNamesInThe PostScriptPageDescriptionLanguage (inventedBy AdobeSystemsFounderAndEx-PARCScientist JohnWarnock),AsWellAsForTheLanguageItself.InAddition, NiklausWirth,TheInventorOf Pascal,CameToAppreciateCamelCaseDuringASabbaticalAtPARCAndUsedItIn Modula,HisNextProgrammingLanguage.

SpreadToMainstreamUsage

WhateverItsOriginsWithinTheComputingWorld,ThePracticeSpreadInThe 1980sAnd 1990s,WhenTheAdventOfThe personalComputerExposedHackerCultureToTheWorld.CamelCaseThenBecameFashionableForCorporate tradeNames,InitiallyInTechnicalFields;MainstreamUsageWasWellEstablishedBy 1990:

DuringThe dot-comBubbleOfTheLate 1990s,TheLowercasePrefixes "e" (for "electronic")And "i" (for "Internet",[22] "information", "intelligent",Etc.)BecameQuiteCommon,GivingRiseToNamesLike Apple's iMacAndThe eBoxSoftwarePlatform.

In 1998,DaveYostSuggestedThatChemistsUseMedialCapitalsToAidReadabilityOfLongChemicalNames,E.g.WriteAmidoPhosphoRibosylTransferaseInsteadOf amidophosphoribosyltransferase.[23]ThisUsageWasNotWidelyAdopted.

CamelcaseIsSometimesUsedForAbbreviatedNamesOfCertainNeighborhoods,E.g.NewYorkCityNeighborhoods SoHo (SouthOf HoustonStreet)And TriBeCa (Triangle Below CanalStreet)AndSanFrancisco's SoMa (SouthOf Market).SuchUsagesErodeQuickly,SoTheNeighborhoodsAreNowTypicallyRenderedAs Soho, Tribeca,And Soma.

InternalCapitalizationHasAlsoBeenUsedForOtherTechnicalCodesLike HeLa (1983).

CurrentUsageInComputing

ProgrammingAndCoding

Template:MainArticle TheUseOfMedialCapsForCompoundIdentifiersIsRecommendedByThe codingStyleGuidelinesOfManyOrganizationsOrSoftwareProjects.ForSomeLanguages (suchAs Mesa, Pascal, Modula, JavaAnd Microsoft's .NET)ThisPracticeIsRecommendedByTheLanguageDevelopersOrByAuthoritativeManualsAndHasThereforeBecomePartOfTheLanguage's "culture".

StyleGuidelinesOftenDistinguishBetweenUpperAndLowerCamelCase,TypicallySpecifyingWhichVarietyShouldBeUsedForSpecificKindsOfEntities: variables, recordFields, methods, procedures, types,Etc.TheseRulesAreSometimesSupportedBy staticAnalysisToolsThatCheckSourceCodeForAdherence.

TheOriginal HungarianNotationForProgramming,ForExample,SpecifiesThatALowercaseAbbreviationForThe "usageType" (notDataType)ShouldPrefixAllVariableNames,WithTheRemainderOfTheNameInUpperCamelCase;AsSuchItIsAFormOfLowerCamelCase.

ProgrammingIdentifiersOftenNeedToContain acronymsAndInitialismsThatAreAlreadyInUpperCase,SuchAs "oldHTMLFile".ByAnalogyWithTheTitleCaseRules,TheNaturalCamelCaseRenderingWouldHaveTheAbbreviationAllInUpperCase,Namely "oldHTMLFile".However,ThisApproachIsProblematicWhenTwoAcronymsOccurTogether (e.g., "parseDBMXML"WouldBecome "parseDBMXML")OrWhenTheStandardMandatesLowerCamelCaseButTheNameBeginsWithAnAbbreviation (e.g. "SQLServer"WouldBecome "sQLServer").ForThisReason,SomeProgrammersPreferToTreatAbbreviationsAsIfTheyWereLowerCaseWordsAndWrite "oldHtmlFile", "parseDbmXml"Or "sqlServer".However,ThisCanMakeItHarderToRecogniseThatAGivenWordIsIntendedAsAnAcronym.[24]

WikiLinkMarkup

CamelCaseIsUsedInSome wikiMarkupLanguagesForTermsThatShouldBeAutomaticallyLinkedToOther wikiPages.ThisConventionWasOriginallyUsedIn WardCunningham'sOriginal wikiSoftware, WikiWikiWeb,AndCanBeActivatedInMostOtherWikis.SomeWikiEnginesSuchAs TiddlyWiki, TracAnd PmWikiMakeUseOfItInTheDefaultSettings,ButUsuallyAlsoProvideAConfigurationMechanismOr pluginToDisableIt. WikipediaFormerlyUsedCamelCaseLinkingAsWell,ButSwitchedToExplicitLinkMarkupUsing squareBracketsAndManyOtherWikiSitesHaveDoneTheSame.SomeWikisThatDoNotUseCamelCaseLinkingMayStillUseTheCamelCaseAsANamingConvention,SuchAs AboutUs.

OtherUses

The NIEMRegistryRequiresThat XMLDataElementsUseUpperCamelCaseAndXMLAttributesUseLowerCamelCase.

MostPopular command-lineInterfacesAnd scriptingLanguagesCannotEasilyHandleFileNamesThatContainEmbeddedSpaces (usuallyRequiringTheNameToBePutInQuotes).Therefore,UsersOfThoseSystemsOftenResortToCamelCase (orUnderscores,HyphensAndOther "safe"Characters)ForCompoundFileNamesLike MyJobResume.pdf.

MicrobloggingAnd socialNetworkingSitesThatLimitTheNumberOfCharactersInAMessage (mostFamously Twitter,WhereThe 140-characterLimitCanBeQuiteRestrictiveInLanguagesThatRelyOnAlphabets,IncludingEnglish)ArePotentialOutletsForMedialCapitals.UsingCamelCaseBetweenWordsReducesTheNumberOfSpaces,AndThusTheNumberOfCharacters,InAGivenMessage,AllowingMoreContentToFitIntoTheLimitedSpace. Hashtags,EspeciallyLongOnes,OftenUseCamelCaseToMaintainReadability (e.g. #CollegeStudentProblemsIsEasierToReadThan #collegestudentproblems).

InWebsiteURLs,SpacesAre percent-encodedAs "%20",MakingTheAddressLongerAndLess humanReadable.ByOmittingSpaces,CamelCaseDoesNotHaveThisProblem.

ReadabilityStudies

CamelCaseHasBeenCriticisedAsNegativelyImpactingReadabilityDueToTheRemovalOfSpacesAndUppercasingOfEveryWord.[25]

A 2009StudyComparing snakeCaseToCamelCaseFoundThatCamelCaseIdentifiersCouldBeRecognisedWithHigherAccuracyAmongBothProgrammersAndNon-programmers,AndThatProgrammersAlreadyTrainedInCamelCaseWereAbleToRecogniseThoseIdentifiersFasterThanUnderscoredSnake-caseIdentifiers.[26]

A 2010Follow-upStudy,UnderTheSameConditionsButUsingAnImprovedMeasurementMethodWithUseOfEye-trackingEquipment,Indicates: "WhileResultsIndicateNoDifferenceInAccuracyBetweenTheTwoStyles,SubjectsRecognizeIdentifiersInTheUnderscoreStyleMoreQuickly."[27]

SeeAlso

References

  1. ^ Template:CiteWeb
  2. ^ Template:CiteWeb
  3. ^ [1] Archived 2008-04-11 at the Wayback MachineAt PurdueUniversityCollegeOfTechnology
  4. ^ Template:CiteWeb
  5. ^ Template:CiteWeb
  6. ^ [2],ByNannetteThacker (05/01/1999)
  7. ^ Template:CiteBook
  8. ^ Template:CiteWeb
  9. ^ Template:CiteWeb
  10. ^ Template:CiteWeb
  11. ^ Template:CiteWeb
  12. ^ Template:CiteWeb
  13. ^ [3]Template:DeadLink
  14. ^ Template:CiteBook
  15. ^ Template:CiteBook
  16. ^ JönsJacobBerzelius (1813). EssayOnTheCauseOfChemicalProportionsAndOnSomeCircumstancesRelatingToThem:TogetherWithAShortAndEasyMethodOfExpressingThem. AnnalsOfPhilosophy 2, 443-454, 3, 51-52; (1814) 93-106, 244-255, 353-364.
  17. ^ HenryM.Leicester &HerbertS.Klickstein,Eds. 1952, ASourceBookInChemistry, 1400-1900 (Cambridge,MA:Harvard)
  18. ^ Template:CiteWeb
  19. ^ Template:CiteWeb
  20. ^ Template:CiteJournal
  21. ^ Template:CiteWeb
  22. ^ Template:CiteNews
  23. ^ Feedback, 20June 1998Vol 158No 2139 NewScientist 20June 1998
  24. ^ Template:CiteJournal
  25. ^ Template:CiteNews
  26. ^ Template:CiteJournal
  27. ^ Template:CiteJournal

ExternalLinks

Template:CommonsCategory

Template:TypographyTerms

Template:UseDmyDates