Archive for July, 2007

Informavore Trap # 2: Information Junk Food

This is a follow-up to my original post about cognitive traps that hinder learning and stunt professional growth. Information junk food refers to any information gathering activity that prematurely satisfies your hunger to learn and provides fleeting emotional pleasure in lieu of actual intellectual nourishment.

Some information junk foods to avoid:
Fattening Abstractions - There is great power in naming things, which is why it is an integral part of nearly all creation stories (i.e. Adam naming all the animals in the Christian Bible). Unfortunately, learning acronyms, buzzwords, and high level abstractions often fools us into thinking we know more than we really do. This is why I’ve interviewed candidates who could talk for hours on end about service oriented architecture, but failed miserably when it came to a simple fizzbuzz programming test.

High Calorie Public Opinions
 - The blogosphere is full of brilliant people who passionately articulate their beliefs. Unfortunately, the human need to fit into a community (open source, java, ruby, agile, alt.net) often trumps the desire to keep an open mind. While the person who originally formed the opinion derived great value from the decision making process, the casual reader who easily adopts opinions like a new piece of trendy clothing gains nothing but unfounded and potentially misapplied biases.

Sugary old Habits
- Paradoxically, the better you become at something, the more difficult it can be to learn new things. Once a habit becomes second nature, we forget that there are other alternatives and that we probably made our original choice at at a time in our careers when we knew less than we do now. This human propensity to stick with things that are comfortable and have worked well in the past is why the most experienced people in our profession are so often dismissed as irrelevant rather than respected.
Some Healthy Alternatives:
Just one more block - The most helpful habit I’ve adopted while running is to respond to my first impulse to stop running with the mantra, “just one more block”. I think this also works well with learning. The next time you feel the urge to fall back on that same worn-out API or unproductive GUI-oriented approach, discipline yourself to take a minute and learn just one new method or one new keyboard shortcut. The investment will pay great dividends down the road.

Empty your Cup
- This is a phrase that I remember from some zen book that I read in high school. The idea is that in order to learn something more deeply, you often have to intentionally forget what you already know so that you can approach things with fresh eyes. The next time you catch yourself dismissing a learning opportunity because it pertains to something you think you already know or have a strong opinion about, pretend that you are a newbie and see if you can glean an new tidbit or perspective.

Bite your tongue
- Every once in a while, I’ll catch myself talking about or recommending a technology or tools that I’ve only read about but never used. I am now trying to get into the habit of not letting myself talk about anything unless I’ve at least downloaded the technology and done a proof of concept for myself. For me, this serves as extra motivation to take the next step in learning.

Approach documentation like a scientist - Treat techniques you read about like an hypothesis that you must scientifically prove with a unit test before you can confirm that it is true. I’ve caught myself several times regurgitating something I’ve read that I thought was very straight-forward only to discover later that I’ve slightly misinterpreted how it works. Documentation and resource sites are subject to the same ambiguousness and misinterpretation as requirements. Don’t trust your understanding until you’ve seen it with your own eyes.

Powershell from 50,000 feet

I’ve been spelunking Powershell lately with Bruce Payette’s excellent book, Powershell in Action, and thought I would take a step back from some of the lower level nuances, such as dynamic type conversion and parameter binding rules, and organize my thoughts at a higher level.

What is Powershell? - It is the new command line/scripting environment from Microsoft that replaces cmd.exe and WSH. You can install it as a small, free OS update on Windows XP, Windows 2003, and Vista as long as you have the 2.0 framework installed.

Why is it Significant? - Microsoft has traditionally been focused much more on the GUI portion of the OS, which made creating administrative tasks much more difficult in Windows than it typically is from non-MS shells like Bash. This new version of the shell not only addresses these shortcomings in functionality, but significantly raises the bar for other shells by being object-based rather than string based. This eliminates most of the text parsing craziness that is usually required in order to consume command line output. Powershell also achieves an enormous amount of functional coverage by exposing all of the major MS API’s, including XML, .NET,COM, ADO, WMI, and ADSI.

Some Basic Concepts

  • Cmdlets - Commands that follow the verb-noun pattern, such as Get-Process or Get-Date. These are actually .net classes that inherit from the base Cmdlet class and can take traditional switches or parameters with arguments. The environment comes with a number of great built in commands, but you can supplement these by installing the Powershell Community Extensions from Codeplex or creating your own that will get automatically loaded into the environment when the shell opens. You can view the cmdlets available on your system by calling Get-Command and then using Get-Help to find out more information about a particular cmdlet.
  • Pipeline - The pipe operator ( | ) allows you to chain together commands in a very concise way by taking the output from the command on the left side of the pipe operator and feeding it as input to the command on the right-side of the operator. This is where the object based paradigm really shines because it allows you to access specific information in the pipeline through properties instead of regular expressions and hard-coded column indexes.
  • Expansive Syntax- Powershell makes extensive use of aliases and pattern matching to ease the transition from cmd.exe and to allow for the terse, write-only experience from the command line that maximizes productivity when producing throw away code. For example, you can use the familiar dir instead of Get-Children when navigating the file system or the shortened alias gps instead of Get-Process when retrieving processes. You can get a list of built-in aliases using Get-Alias and even create your own using Set-Alias.
  • Provider Stores - These expose various data stores such as the registry, certs, and environmental variables as drives, thus allowing you to navigate a registry hive by simply typing cd hklm:. Open source projects have been created to expose VSS, SQL, and Exchange as providers. Use Get-PSDrive to enumerate the available drives.

A Quick Sample Script (Query top 5 CPU consuming process on a machine)

get-process | sort-object -desc CPU | select-object -first 5 processName, cpu | format-table -auto

Now a little more concisely with aliases

gps | sort -desc CPU | select -first 5 processName, cpu | ft -auto

If you want a good 20 minute introduction to the topic, I recommend listening to this old HanselMinutes podcast. It’s over a year old, so the podcast uses the old code-name Monad, but it provides a great high level overview. If you enjoy it, check out later episodes where he interviews Bruce Payette, the dev lead on the Powershell team, and Jeffrey Snover, the architect.

« Previous Page