::::::::: PowerShell :::::::::
Monday, January 16, 2006
  Simple tools for complex jobs
While listening to "Inside the Net" podcast episode #5 "Jason Fried of 37Signals", I have realized something.

As an application or scripts gets more mature, they tend to do more stuff than it supposed to do. For an example, Adobe Photoshop is extremely bloated so that it includes a lot of functionalities that normal users are not even aware of.

Now, we could come up with an analogy that, if you would want to disassemble, you would normally use screw drivers. But if you have a Swiss Army knife, you do can get a job done but you would have to search for the right tool that's bundled with the Swiss Army Knife. Swiss Army KNife can get other tasks accomplished but it's bloated.

So what I am trying to accomplish in this Blog is that, I would like to create simple tools or scripts or functions to accomplish other many things.

For example, when using Windows Forms, one would normally have to import "System.Windows.Forms" through excruciatingly long statement as followed.


Would you actually like to have multiple of those "[System.Reflection.Assembly]::LoadWithPartialName" functions in your script?
Coming from a C# community, i could not stand such long function names clogging up my scripts.

So I have created a such script like,

function using-library {
param($ns = $(throw "Enter Namespace to import"), [bool]$SuppressOutput = $false)

trap { throw "Could not import Namespace $($ns)" }

if ($SuppressOutput) {
} else {

MSH>Set-Alias using using-library

Now, in a script, one can simply use C# style "USE" statement in their scripts without having to know inner details on how to import and can simply concentrate on what his/her script needs to do.
What is more great about such abstraction is that, since "LoadWithPartialName" function is now obsolete according to WinFX document, one can simply change function implementation of "using-library" without having to change all scripts with "LoadWithPartial" name.

Well, the predicament I am in now is, HOW can I put all the scripts in one place so that it'd be easy to to use all the functions, load them or unload them with ease. Ah there is also a name collision issues that I have to cope with. It'd be nice if MSH had one of those Namespace concepts as in .NET library.
Tags :
Comments: Post a Comment

Links to this post:

Create a Link

<< Home
Let's get lazy with PowerShell!

Location: Flushing, NY, United States

Experimenting with a different format of blogs...

10/01/2005 - 11/01/2005 / 11/01/2005 - 12/01/2005 / 12/01/2005 - 01/01/2006 / 01/01/2006 - 02/01/2006 / 02/01/2006 - 03/01/2006 / 03/01/2006 - 04/01/2006 / 04/01/2006 - 05/01/2006 / 05/01/2006 - 06/01/2006 / 06/01/2006 - 07/01/2006 / 07/01/2006 - 08/01/2006 / 08/01/2006 - 09/01/2006 / 10/01/2006 - 11/01/2006 / 11/01/2006 - 12/01/2006 /

Powered by Blogger