Giter Club home page Giter Club logo

Comments (7)

Jaykul avatar Jaykul commented on May 23, 2024 2

Yep, I agree with that. In general, camelCase for variables, but PascalCase for parameter names because parameters are expected to be PascalCase and it affects tab-completion/intellisense, etc.

I'm not sure the style guide needs to specify a preference for capitalization though, apart from function names and parameters -- although I will admit I have a strong preference for $camelCase vs $python_style_separated_words ;-)

from powershellpracticeandstyle.

mattmcnabb avatar mattmcnabb commented on May 23, 2024 2

I tend to use PascalCase everywhere, mainly because it looks more formal. Also, if I define a parameter with PascalCase, tab-completion copies that in the body of the function so that's generally what I stick with.

@Jaykul do you have any arguments for a certain style, like camelCase? I've seen some who attempt to differentiate variable scope with casing, but it seems too complex and delicate to support.

from powershellpracticeandstyle.

Jaykul avatar Jaykul commented on May 23, 2024 2

I don't think there are any arguments for certain styles that can't be countered. Clearly it's "easier" to type lower case letters, but $variable vs $Variable is hard to argue considering that leading $ ...

The fact is that the built-in variables are also all over the map. Most people tend to use all upper case for "constants" but PowerShell uses all lower case: $null, $true, $false, $args, $input ... and then sometimes uses upper case: $PID, $HOME, $PSHOME, $PWD and $LASTEXITCODE ... but all the preference variables are PascalCase: $ConfirmPreference, $DebugPreference, $ErrorActionPreference, $InformationPreference, $MaximumAliasCount, $MaximumDriveCount, $MaximumErrorCount, $MaximumFunctionCount, $MaximumHistoryCount, $MaximumVariableCount, $ProgressPreference, $PSBoundParameters, $PSCommandPath, $PSCulture, $PSDefaultParameterValues, $PSEdition, $PSEmailServer, $PSScriptRoot, $PSSessionApplicationName, $PSSessionConfigurationName, $PSSessionOption, $PSUICulture, $PSVersionTable, $VerbosePreference, $WarningPreference, $WhatIfPreference .....

And then there's $PROFILE in powershell.exe, but $profile in ISE?

from powershellpracticeandstyle.

dotps1 avatar dotps1 commented on May 23, 2024 1

i do UpperCaseEachWord for parameters for functions, and lowerCamelCase for variables inside functions.

from powershellpracticeandstyle.

gerane avatar gerane commented on May 23, 2024

from powershellpracticeandstyle.

gerane avatar gerane commented on May 23, 2024

from powershellpracticeandstyle.

rkeithhill avatar rkeithhill commented on May 23, 2024

Is there more than just previous language experience that would make camelCase better?

Probably not but for us C# devs, it's hard to shake. I still tend to use camelCase for local variables and PascalCase for everything else (parameters, script/global variables).

It might be better to ask the VB crowd about casing conventions for variables, since VB also has case-insensitive variable names IIRC. I suspect there probably should be a recommendation to use the same casing for a variable everywhere e.g. if I initialize $foo try to use $foo everywhere instead of $FOO or $Foo or $FoO.

from powershellpracticeandstyle.

Related Issues (20)

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.