Introduction - Home - NetApp Community
WFA Coding GuidelinesContents TOC \o "1-3" \h \z \u 1.Introduction PAGEREF _Toc292121307 \h 22.PowerShell PAGEREF _Toc292121308 \h 22.1.Variables PAGEREF _Toc292121309 \h 22.2.Indentation PAGEREF _Toc292121310 \h 22.ments PAGEREF _Toc292121311 \h 32.4.Logging PAGEREF _Toc292121312 \h 32.5.Error Handling PAGEREF _Toc292121313 \h 32.6.General PowerShell Conventions PAGEREF _Toc292121314 \h 43.Functions PAGEREF _Toc292121315 \h 44.String representation PAGEREF _Toc292121316 \h 55.SQL PAGEREF _Toc292121317 \h 56.Dictionary Entry PAGEREF _Toc292121318 \h mon WFA PowerShell Functions PAGEREF _Toc292121319 \h 68.References PAGEREF _Toc292121320 \h 68.1.PowerShell PAGEREF _Toc292121321 \h 68.1.1..NET Framework Naming Guidelines PAGEREF _Toc292121322 \h 68.1.2.PowerShell code style PAGEREF _Toc292121323 \h 68.1.3.PowerShell Try/Catch/Finally PAGEREF _Toc292121324 \h 68.1.4.PowerShell Automatic Variables PAGEREF _Toc292121325 \h 68.1.5.PowerShell data types PAGEREF _Toc292121326 \h 78.1.6.PowerShell comparison operators PAGEREF _Toc292121327 \h 78.1.7.PowerShell logical operators PAGEREF _Toc292121328 \h 78.1.8..NET capitalization styles PAGEREF _Toc292121329 \h 78.2.Functions PAGEREF _Toc292121330 \h 88.2.1.Official Java code conventions PAGEREF _Toc292121331 \h 8IntroductionThis document provides general WFA coding guidelines, naming conventions and recommendation.PowerShell The following section describes PowerShell related naming conventions and recommendations.Variables#RuleExample1All variables must start with the ‘$’ character$variable2Script input parameters:Pascal case [more]No underscoresNo abbreviation$VolumeName$AutoDeleteOptions$Size3Script internal variables: Camel case [more]No underscoresNo abbreviation$newVolume$qTreeName$time4Functions:Pascal case [more]No underscoresNo abbreviationGetVolumeSize5Names are not case sensitive$variable is equal to $Variable6Variable names should be plain English and related to script’s functionalityUse $name and not $a7Declare explicitly the data type for each variable[string]name[int]size8Mind illegal characters such as:Special characters “! @ # & % , .”SpacesPowerShell reserved keywords9Input parameters grouping. Group the input parameters – put mandatory first and separate mandatory and optional parameters by empty line10All input variables must be commented using HelpMessage annotation [parameter(Mandatory=$false, HelpMessage=”The size of volume in megabytes”)][string]$Size11“Filer” cannot be used as a variable name; use “Array” instead12Use ValidateSet annotation in cases where argument gets enumerated values [parameter(Mandatory=$false, HelpMessage="Volume state")] [ValidateSet("online", "offline", "restricted")] [string]$StateIndentation#RuleExample1TAB is equal to 4 empty spaces2Use tabs and curly braces to visually show where a block of code begins and ends3Add blank lines between sets of operations or chunks of codeComments#RuleExample1Use # character for single line comment2Use # character for end of line comment3Use <# and #> characters for block commentLogging#RuleExample1Use WFA Get-WFALogger Cmdlet to perform logging2Log every action that requires interaction with internal packages, such as: DATAONTAP, PowerCLI etc.3Log every relevant argument passed to internal packageError Handling#RuleExample1Mind terminating and non-terminating errors 2Use general try/catch statement if the type of incoming exception is unknown [more]3Use specific try/catch statement if the type of incoming exception is known4Use finally statement to release resources5Use PowerShell Automatic Variables in order to access exception information [more]$_.Exception.MessageGeneral PowerShell Conventions#Rule1Use Cmdlets when possible. Only resort to invoking .NET code when there is no Cmdlet available2Don’t make scripts more complicated than they need to be3Use variables that make it easy to understand what you are doing in your script4Comments in code are great, but your code should be readable and understood without them or in other words - let the code document itselfFunctionsThis section provides general guidelines for WFA function definition#RuleExample1Function name must use Camel case [more]calculateVolumeSize2Variable names should be plain English and related to function functionalitysplitByDelimiter3No abbreviationscalculateVolumeSize and not calcVolSize4Function definition should be done according to the official Java Programming Language guidelines [more]String representationThe following section defines general conventions for creating string representation for Dictionary Entry and Command Definition. Note, that the behavior of string representation is different in those entities:Command Definition – only the command parameters can be used in string representationDictionary Entry – since dictionary entries can refer different dictionary entries, string representation may contain attributes of root dictionary entry and attributes of referred dictionary entry (using XPath notation)Additionally, note that the string representation feature is too flexible to be defined by conventions. Hence the following rules are only general recommendation.#RuleExample1Dictionary Entry string representation should contain only useful information2Mind the limited space for displaying the Dictionary Entry representation3Try not to use attributes that does not have any value since it will be displayed as “NA” which is not useful4Separate different entries in string representation using delimiters such as: “[ ] , / :”ArrayName[ArrayIp]5Try to give meaningful labels to every value in string representationVolume name=VoumeNameSQL#RuleExample1SQL reserved keywords must be use upper caseSELECT id FROM wfa.filter2Table and column names must be in lower case3Separate words with ‘_’ character, no spaces alloweddictionary_entry4Table name will be defined in the single (table itself a collection of 1 or more entries)function, not functions5Foreign key name – fk_<table>_<column>, where:Table – name of the table without the schemaColumn – the name of the referring column fk_cache_query_cache_table_id6Unique key name – uk_<table>_<description>, where:Table – name of the table without the schemaDescription – if there is a single unique key in the table it must be the unique column name; in cases when table contains multiple unique keys it can contain descriptionuk_filter_name – means that column name is unique in table filteruk_data_provider_type_keys – means that table data_provider_type has a multiple unique keys7All reference columns must be named <target_table>_<target_column>filter_id8Avoid:AbbreviationConcatenationAcronym-based names9Name all auto-increment primary keys idDictionary Entry#RuleExample1Attributes and references in lower caseaggregate2Separate words with ‘_’ character, no spaces allowedresource_poolCommon WFA PowerShell Functions#FunctionParametersDescription1Get-WFALoggerMessage – the messageLog level – ERROR, FATAL, INFO, WARN, DEBUGSend log message to the WFA server2Connect-WFAControllerArrayIp – array IP to connect toConnects to array. Uses WFA authentication in order to do that, i.e. looks for credentials for the provided IP defined in WFA data Framework Naming Guidelines code style Try/Catch/Finally Automatic Variables data typesTypeDescription[int]32-bit signed integer[long]64-bit signed integer[string]Fixed-length string of Unicode characters[char]A Unicode 16-bit character[byte]An 8-bit unsigned character[bool]Boolean True/False value[decimal]An 128-bit decimal value[single]Single-precision 32-bit floating point number[double]Double-precision 64-bit floating point number[xml]Xml object[array]An array of values[hashtable]Hash table objectPowerShell comparison operatorsOperatorDescription-eqEqual to (not case sensitive by default)-ceqEqual to (case sensitive)-ieqEqual to (case insensitive)-ltLess than-gtGreater than-geGreater than or Equal to-leLess than or equal to-neNot equal toPowerShell logical operatorsOperatorDescription-notNot!Not-andAnd- capitalization stylesStyleDescriptionExamplePascal caseThe first letter in the identifier and the first letter of each subsequent concatenated word are capitalizedBackColorDataSetCamel caseThe first letter of an identifier is lowercase and the first letter of each subsequent concatenated word is capitalizednumberOfDaysisValidUpper caseAll letters in the identifier are capitalizedIDIPFunctionsOfficial Java code conventions ................
................
In order to avoid copyright disputes, this page is only a partial summary.
To fulfill the demand for quickly locating and searching documents.
It is intelligent file search solution for home and business.
Related download
- getting started with microsoft powershell
- powershell new feature in powershell
- the complete guide to powershell punctuation
- powershell for beginners
- securing powershellin the enterprise acsc
- powershell illinois institute of technology
- powershell study notes amr eldib
- windows powershell specification
- scripting transparency for antimalware engines
- vbscript function cnf1g
Related searches
- introduction to financial management pdf
- letter of introduction sample
- argumentative essay introduction examples
- how to start an essay introduction examples
- introduction to finance
- introduction to philosophy textbook
- main home first community credit union
- first community bank 1 community place va
- home and community services texas
- community home health and hospice
- introduction to community development notes
- an introduction to community development