//
stai leggendo...
domanda

Scripting games-major dislike

Richard Siddaway's Blog

One of the things we were asked to blog about as Scripting Games judges was things we liked and disliked. This code is a major dislike

Get-ChildItem $sourceDirectory | ? {$_.PsISContainer } |
     % { $subDirectory = $_ ; Get-ChildItem (“$sourceDirectory\$subDirectory”) -Include *.LOG -Recurse } |
         ? { $logFile = $_ ; $logFile.LastWriteTime -le $modifiedCutOffDate } |
             %  { $logFileAndSubDirDictionary.Add($logFile, $subDirectory) }

Two things really make this stand out as how not to do things:

  1. Using % & ? as aliases in a script. They are tolerable (just) in an interactive command but have no place in a script. Tab completion is so easy. Use the proper command.
  2. Putting multiple commands on a line separated by ;      It makes the code hard to read and awkward to work out whats going on. It also makes script testing, debug and maintenance much more difficult

Avoid these two things…

View original post 3 altre parole

Annunci

Discussione

Non c'è ancora nessun commento.

Rispondi

Inserisci i tuoi dati qui sotto o clicca su un'icona per effettuare l'accesso:

Logo WordPress.com

Stai commentando usando il tuo account WordPress.com. Chiudi sessione / Modifica )

Foto Twitter

Stai commentando usando il tuo account Twitter. Chiudi sessione / Modifica )

Foto di Facebook

Stai commentando usando il tuo account Facebook. Chiudi sessione / Modifica )

Google+ photo

Stai commentando usando il tuo account Google+. Chiudi sessione / Modifica )

Connessione a %s...

%d blogger hanno fatto clic su Mi Piace per questo: