Friday, November 11, 2011

Two days ago, I attended the IASA(International Association of Software Architects) meeting in Atlanta (http://www.iasaglobal.org/iasa/Atlanta_Chapter.asp) . The presenter Joseph DeCarlo   spoke about doing iOS development in the enterprise. After the presentation, I got to talking with him about his development experience. We spoke about a variety of topics; like his move from the .Net development to Mac development, and we spent time discussing SCM(Source Control Management) packages - including  TFS(Team Foundation System) and Git. The team he works with is moving away from TFS as they felt that TFS was "too heavy" a process, and they moved to Git to make thier development process  "lighter" (more agile).  I have been trying to get my employer to move toward TFS as a standard (what we are required to use now is an abomination from the software graveyards) - so this was an interesting discussion for me.  It left the impression that the Distributed version control approach, in this case Git, added an agility to a team, that TFS might not have.

 

Joseph DeCarlo said that he has learned enough about Git to teach it, and do presentations on it. When he first started looking at Git he was not so sure about it, and then he read two books about it, and was sold - to the point that he claims he would not use another source control system.  He said that the impact of using Git on his development experience was as large as going from C++ to .Net ( he worked  for 8 or more years in each of them). The discussion made me want to finally pull the trigger on doing the install of Git on my machine.

 

I still looked at some more posts on the "Git vs Mercurial" topic(more info gathering) -

 this post  tries to claim that Git is like MacGyver and Mercurial is like James Bond -it  was well written - however is a bit dated now - as Mercurial has added some new functionality (see the comments on the post).

Within this post,  the point is made that the community of developers is more important than the tool - which I agree with, and in my mind decides the tool to some degree- If that is the community that is working on the stuff I am interested in.

And finally a post from someone who used both products for over a year, proficient in both - it speaks about how you approach the "version control hygiene" can impact the entire project in using Git.

 

I have access to Safari Online, so getting books to read on a topic is great - and I looked up a couple of books on Git. From the book Pro Git - by Scott Chacone,  in the first chapter of the book, he cited the link  http://code.google.com/p/msysgit/ I had put in my earlier research post on "Git or Mercurial".  The link  from that site to "Install msysgit"went to https://github.com/msysgit/msysgit/wiki/InstallMSysGit - which went nowhere for me  --not reachable  - but there on the far left of the page ( http://code.google.com/p/msysgit/) are several install (exe) programs - I downloaded and ran the Full install program;  The executable  compiled and setup Git on my machine and the last bit of the install shows commands to create the shortcuts - I created a Start Menu and Desktop shortcut.  So now I have pulled the trigger and can  explore Git on my own.

 

 The experience of running the install (pretty painless) was far easier to do - than to do the research. I just like to know what it is I am getting into, and have an interest in seeing that there is a value in going in any certain direction before I go there. The discussion with Joseph DeCarlo had given me the push I needed to pull the trigger.

 

Now I have to learn the basics of how to use it!

After the install the help file is great place to start.

 

C:\msysgit\msysgit\doc\git\html\git.htm

 

BTW - I Did encounter an interesting interactive Git "cheat sheet"  ; (click in the horizontal bars you find there) - but need to learn the basics first.


 I hope I can carve out the time to learn it, and use it,  at least to some degree - over the next year.

Friday, November 11, 2011 11:30:50 AM (Eastern Standard Time, UTC-05:00)
 Sunday, October 30, 2011
A few years ago, I heard about  a product that was in development called Mole that was used for .Net debugging visualization(now the company is called Moloscope). Today, I came across a "topic category" called "moles" in a question on Stackoverflow- initially I thought this was the same thing- but it is not. Apparently, Microsoft research developed an  Isolation framework that allows test code to create a "detour" - a detour can replace the .Net framework calls with your own delegate - to execute your unit test with - by reworking the IL code for the .Net Framework code. The Microsoft Research group named it Moles. A one letter difference between very different tools.

The Moles Framework was new to me,  and since it was connected to Pex, a "white box" testing tool I heard about back in 2008, - I was very interested in knowing more on this. Code Project has an article on the combination of Pex and Moles usage in testing applications.

In the StackOverflow question I started with, there were links to three training videos on the use of Pex and Moles, delivered by Peli de Halleux in a class in Spain, so it starts in Spanish but the class is in English.  'Video Part 1'(00:58) starts with a software test that requires access to a hard disk - and by the end of the video they have replaced that test disk access with a Moles delegate and even step into the debugger with it. This video used overlays to ensure you had a camera view of the instructor or monitor - even when people were walking in front of a camera - your view is of the subject (some walk throughs do occur) -so it is one of the better live presentation video recordings I have seen. 'Video Part 2' (1:57), and 'Video Part 3'(2:26).

InfoQ has a video presentation entitled "Test First v.Next with Pex and Moles"  presented by David Star (from Pluralsight) given at DevTeach in Belgium during October 2011. In the presentation he introduces Pex, and then the use of Code Contracts which Pex recognizes, and then works in how to use Moles framework. This presentation is a good introduction to the use of all three tools for development work. Mr Star clarifies the framework as not being a "mock" framework.

The combination of the tools should prove useful in the right context. With an end goal of having good tests for your code, and where you need to fake, detour, round some difficult bits that can cause issues.

Sunday, October 30, 2011 11:11:40 AM (Eastern Standard Time, UTC-05:00)
 Sunday, June 19, 2011
I was thinking that I needed to download this blogs data files onto my new laptop and play with the site locally, and to get that I have usually found an FTP program to manage the communication. So I googled for "FTP Windows 7" and encountered a tip on getting an FTP site to behave as a native disk on the machine. Nice trick for saving to the website.
You do have to click on the link to connect to Web - and then I was able to put in the website address userid and password and now I have the ability to browse the website files and folders from my machine. Making a backup of the files this way is not as good as the use of FTP which shows you a progress  of the processing status better. This shows you a file at a time and a  time estimate for copying across.

This may be a very convenient way of using the website though - and I will just have to experiment with it more.

Sunday, June 19, 2011 10:14:57 AM (Eastern Standard Time, UTC-05:00)
 Sunday, June 05, 2011
During the last year, I have come across a few projects that I would like to download and experiment with; the stopping point has been that they use the SCM tool - Git. A comment from a recent DeepFriedBytes podcast with Jeremy Miller indicated that many Windows developers seem to use Mercurial, and that other developers (non windows being implied?) use Git.  I have used TortoiseSVN successfully, but the start-up story with Git does not appear to be  "straight forward". During the DeepFriedBytes  podcast, there was mention of using Powershell with Git - which I had seen mentioned in Ayende's blog (He wrote Rhino-Mocks, RavenDB, and a book on DSLs in Boo). So this post is to collect some research items on how what these two source control packages are and the setup dependencies they require.

As I stated at the start - my impression of Git is that it is not straight forward to get started with; Whereas Mercurial seems to be very simple to use and is supported on Codeplex. The Mercurial association with Codeplex alone, would make it be preferred by Windows developers. Codeplex works with TFS(Team Foundation System),Subversion, and Mercurial. There is a Free TekPub video demonstrating how to use Mercurial on a Codeplex project ( Tekpub has  a full Mercurial training course of 3 hours for about 20 dollars).

In listening to a podcast  - This Developers Life episode on Pressure - The Stackoverflow team discussed many things and one point they touched on was  - they went to Mercurial - and decided against using Git. The decision to use Mercurial for them was more of a workflow issue that they needed within the Stackoverflow teams shared working process.

Git - being a command line tool - has attracted some development tools to make it simpler - TortoiseGit, and Posh-Git(Powershell enabled Git). There was a series of posts on the topic of Powershell and Git by Mark Embling
It appears that some of the collaboration on this set of tools was being done on Google Groups - but based on the page there - the sharing of files and update ability is going away Aug 2011. There is a  GitHub project for this Posh-git

Daniel Hoelbling, in Sept of 2010, posted how the Posh-git tools got easier; in October 2010 - he posted that he had moved to Git from  Mercurial. Dan also posted a link on the visual studio 2010 tool  Git-Source-Control-Provider - posted March 29, 2011. There is an installer for VS 2008 - and a VS 2010 Extension you can use from the gallery. On the codeplex site there is a video on how to install Git on Windows 7 by Dan Stewart - and his video goes through the process of installing on Windows 7 - which you note is running MINGW32(Cygwin) console window. Dan Stewart puts up a bunch of Git reference info on a delicious link.


The msysgit - creates a development environment on your machine allowing you to build Git on your machine. The Git website - in describing Windows installs for git - leads to the Cygwin (which is a Linux API based development environment for Windows) or as the Git site refers to msysgit -"install the Git Development Environment for Windows" - which is a confusing roundabout way of saying -   msysgit creates a cygwin setup and allows the build of git so you can use it from your Windows machine. These elements  are the prerequisites for using git - and why I have really wanted to wait before pulling the trigger on installing Git (in short - emulate Linux within Windows so you can use a source control system - seems like it a bit obtuse in how it gets there).

Since the CodePlex VS2010 extension is available in the online Gallery - I knew I should be able to see how it would be setup from the IDE. I installed the Git-Source-Control-Provider and you use the Tools>Options>Source to select Git as your source control. When you do that - you see that it has setup commands for the msysgit and the Git-Extensions and TortoiseGit all in the same setup dialog window. So it seems like if you are going to commit to using git - you have a few things to install and the configure under Source Control plugins within VS2010. It may be simple once you get to that point, but it seems to have a lot of parts that this approach needs to make it work - no wonder people like Mercurial (See the Tekpub video link earlier).

So, if Mercurial is so easy, and Git seems problematic at the startup - why would I want to look into Git more? - the projects that I have found or heard of that seem to be on Github - a free repository for open source projects. 
  • SpecFlow for TDD/BDD development is on GitHub
  • MSpec also for BDD development is also on GitHub
  • PSake (pronounced like the Japanese drink) an automated build tool from Powershell is on GitHub
Are just a few of the items that I look at -- and keep me pondering about Git and whether it is worth the very obtuse install process to be on my development machine so I can experiment with these libraries. I keep hoping there is a better way.
It is probably just a matter of time ( and more research) and I will probably pull the trigger and do it - just not yet.






Sunday, June 05, 2011 4:35:09 PM (Eastern Standard Time, UTC-05:00)
 Friday, April 08, 2011
 #
 
In a recent project, I decided that I would use NUnit for testing functions during my development. There were a couple of things I learned in using it within Visual Studio 2010.

First, I read that the Nunit.config tags were needed within 2010 - as it defaults to .Net 4. NUnit installs to the "C:\Program Files\Nunit<version>". Within that is the "bin\.Net-2.0 folder. There is a config file "nunit.exe.config" that is used when using the GUI for testing. right after the configuration tag  I read that you need to add:

<startup>
<requiredRunTime version ="4.0.30319"/>
</startup>

I am using Nunit 2.5.9 - and without those tags - it still worked for me.

The other thing I learned was what would normally be an App.Config file needs to be a totally different file. You need to create a config file that matches the NUnit Project file name - and it must be located in the same directory as the NUnit Project file - so the NUnit GUI can find it.

Our project structure has a folder for Dependencies where we store DLLs that get used in the project - but might not have the source in the project. I created my NUnit Project file  in that folder. If that file is called NUnitProjectTests.nunit - there must be a config file called NUnitProjectTests.config - and that is used as your App.Config while running the GUI tests. In my project it is not in the "bin\Debug" folder - it's in a totally different folder.
You just need to remember to set the values in there and make them match your real app.config for your project output.

Friday, April 08, 2011 9:41:45 AM (Eastern Standard Time, UTC-05:00)
 Tuesday, January 25, 2011
In 2008, I attended the Microsoft Professionals meeting (Atlanta) where Shawn Wildermuth gave a presentation on Domain specific languages or DSL's. The concepts were an introduction into a Microsoft product development that used the code names   "OSLO",  "M", and "Quadrant" that was previewed in part at the PDC2008 (Professional Developer Conference) which has mostly morphed into something else by PDC2009. Shawn produced three articles for MSDN on the topics of "OSLO" and "M". In the 2008 presentation I attended, Shawn introduced the premise that we use DSL's already today; SQL, XAML, Make, Ant/Nant, MSBuild, regular-expressions, even musical notation are all examples of DSL's. From that talk, the idea of software development DSL's  was planted - even though the technologies that had prompted his discussion have been morphed into new forms within Microsoft - the conclusion  from this argument is that a set of text statements ( or specific symbols like music or regular expressions) can be declared and used to achieve a desired result - and within programming - results in how executing code processes those results. A concise grammar and syntax, that declares what you want to do but not how you do accomplish that - regular expression syntax is a great example. Software development using a DSL, is an idea that continues to cross my path. I thought I would try to capture some of the variations I have seen in how various developers and architects approach the concept of creating and using DSLs.

Martin Fowler wrote the book on Domain Specific Languages where he describes the 3 types of DSLs.
There are some early Oslo software preview videos out on the Microsoft site that show the language M being used to generate a DSL grammar within the tool called Quadrant. This is what Martin Fowler referred to as a "DSL workbench"- where the tool builds the DSL. Martin Fowler identified two other main categories of DSL; the External DSL, and the Internal, or Embedded DSL. External DSL's are often quite complex - and rarely come to general usage. Internal, or Embedded DSL's are abstractions over an API, or framework, within an application.

The idea of a DSL being used was briefly touched on in the Jan 2009 DotNet Rocks episode with Aslam Khan a software architect that lives in South Africa. The company he works with uses this to achieve Domain Driven Design (DDD). "Write a story that describes a problem", and understand that little piece, to understand the domain. "Something that describes it completely - that does not bleed into the other", which build up a dependency graph, it exists in context to the other things - behind each story. A story about the problem - the domain. The more you reveal incorrect assumptions in the dependency graphs and correct them, you don't have to prune source code trees -so you get smaller source code trees, and designing API's around the stories - means changing the granularity of the stories - not modules. In the podcast (just after 38:41) they describe a misunderstood story - that would have produced an incorrect system design - but writing out a story, that the users can understand - allows for corrections can be made before hand. Understanding the user's vocabulary, and you can write it in those terms, then you have the basis to build on(this goes back to the Eric Evan's Domain-Driven-Design "ubiquitous language"). It helps other people later on to understand the language of the application. Aslam Khan uses a Wiki to capture that language - and refers to the "Wiki as code" (about 44:44 in the podcast). He refers to it as "a DSL captured in business terms - that cannot be executed - but at that point you can start writing code". After listening to that podcast(in 2009), I went to Aslam's website - and discovered his posting about using Cucumber and driving it down into Rspec. That led to my reading of a post about Ruby and the latest on Ruby testing - using cucumber. (There is a language called Gherkin used with Cucumber to create a Ruby testing framework). The dynamic nature of Ruby - and the concept of Metaprogramming - became connected to the idea of how one could produce a DSL. Aslam Khan stated it, on his blog, as "the Code is the data" behind a DSL, and he encouraged learning about AST's (Abstract Syntax Trees) which to me connected directly to .Net Expression Trees - the basis of Microsoft Dynamic Language Runtime(DLR) in .Net 4.0.  DSL's can become Expression Trees which in turn can become running code in the DLR. At least, in theory, that would be one Dynamic-Language approach to implementing a DSL(There may be some limitations on how that can occur).
 
During 2010, I picked up a copy of Orin Eini's(a.k.a Ayende Rahein) book called "DSL's in Boo - Domain Specific Languages in .Net". (he did an interview in March 2010 with DotNetRocks on this topic).Ayende is known in the .Net development world for RhinoMocks( a mocking framework), his work on NHibernate(his company makes a profiler for NHibernate and EntityFrameworks), and now his RavenDB - document database project. Somehow, he also managed to have written a book on DSL's   - the guy is prolific at producing content - whether you see his coding output(RhinoMocks,RavenDB), his blog, and now his book.  In his book, he describes how he builds his own DSL's using the .Net language Boo as the foundation, as it gives him a parser,lexer, and great extensibility points, that compile into .Net code - that is not based on the DLR. He shows how the Boo language allows for defining your own expressions that can then be compiled - statically.  Boo is based on the released ECMA standard for the CLI. Interestingly -both the Boo Language, and the ECMA CLI standard, had recent updates(at this writing) Boo 0.9.4 was updated Jan 2011, and the ECMA Standard December 2010. Boo has some capacities that make the language very powerful. It can be an object oriented language, and it can do functional composition (where functions are first class citizens like those in F#), it has 'Syntactic Macros', and it has an extensible compilation pipeline - which is what the creator, Rodrigo B. de Oliveira, wanted to have in the first place, and it can run on multiple platforms (Windows CLR and Linux Mono). Boo has its roots  based on Python Syntax and looks like it has some great potential.  To use Boo that as the basis for creating a DSL seems like a very interesting choice - here it would be a statically typed implementation of a DSL. This could be a way of generating a concise Internal, or External, DSL that works for the users and programmers alike within a given domain. Ayende's book gets into the details of using boo for creating your own DSL.

I found a few entries that related how Powershell could be used at the basis of a DSL. There is a blog post from Keith Hill on how Powershell's syntax flexibility allows you to create a internal DSL. Doug Finke, a Powershell MVP, posted something that went back to the Oslo starting point from a Powershell point of view. Doug Finke shows implementing an OSLO grammar syntax using Powershell, based on the concepts originally introduced in that early video of the M Language example. So from Dynamic Languages or Scripting tools we can find approaches to creating DSL's today.  Doug Finke connected the concepts of DSL, DRL, and Boo; all the ideas together in his post "Creating a unified programming model on top of .NET" He cites "Trends and Directions in programming languages" from Anders Hejlsberg.  DSL's could certainly be part of that mix in creating solutions.

Jeffrey Snover, the architect of Powershell, had a discussion in 2008 on DSL's with Martin Fowler and Neal Ford from Thoughtworks. (recording on Channel9). In this talk they made the point that a DSL can be an External DSL, an Internal DSL or a 'workbench' with tools wrapped around it. Martin Fowler made the point that not many successful DSL's have been done starting from the business side and working toward the API - but that is where the concept is the most powerful, they made the point that it is usually an abstraction of an existing API that simplifies the underlying API - and that DSL can be replaced with the word 'Framework' and mean the same thing. Jeffrey Snover also posted that Powershell could be used to create DSL's by limiting the syntax. The key piece he refers to is the data segment SupportedCommands - which he alludes to as a way to limit a DSL done in Powershell.

Karl Prosser referred to the Powerboots library for Powershell as a DSL in a blog post. It is a Powershell set of commands that are specific to using WPF from within Powershell - which stays with the concept that it  is limited to that specific domain.

Sometimes the use of a Fluent API - can be used to write code that is very readable and expressive - such that it becomes an internal DSL within the general purpose language(Steven Hoisee blog has some coverage on this).  I came accross a paper on how JMock was developed and how they worked toward incorporating a Fluent API as part of their own Embeded DSL within the framework.

Martin Fowler, who took the time to write the book on DSL, has a post on BusinessReadableDSLs. Where the idea is different than business-writeable DSLs. That was the impression I got from Aslam Khan's use of Cucumber - that the business could read the DSL and confirm if it was correct or not.
Martin Fowler invokes the comparison to COBOL - which was supposed to be an english way of telling the computer what to do - and begs the question - how is this one different?  My impression is that the a correct implementation of a DSL is declarative - it describes what you want to do, now how you do it - and having programmed in COBOL - it is an imperative approach, not a declarative one.

Developing a DSL, based on the Jeffrey Snover video, leads me to see that in a DSL you have vocabulary and you have grammar that must be decided on - and the idea of keeping it small seems to be important. Just enough to keep and simple - and no simpler.

Jeremy Miller(Creator of the IOC container - StructureMap, an MVC framework called FubuMVC, and a testing tool called StoryTeller) did a presentation on creating Internal DSL's at Oredev in Oslo - Nov 2010.
He  contributed to the Fluent NHibernate project, and incorporated the use of an Internal DSL in these projects - and in the presentation he goes over some of the difficulties of using and developing an Internal DSL using the C# 3.0 language features. He touches on the separation of the Runtime and Configuration model in building a DSL, and that testing an internal DSL for configuration is very difficult - you can test the runtime model more easily, and then make sure your configuration model works correctly. (the video is a bit grainy - and a few of the questions, that came from the audience, are not heard - but the concepts that were used in creating an internal DSL are shown pretty well.)

From this set of touch points - on the various flavors of DSL's, it is something that can be done in a variety of ways. The simplest form is the internal or embedded, perhaps as a Fluent API approach. This simple form of a DSL can be for a small team that produces repetitive code, or business rules that are needed in in either a static or dynamic fashion - but still being an internal abstraction - within a small domain. Then there is an external DSL - and that would need to have a the same considerations as a full blown computer language - as the publishing of an External DSL approach tends to get the syntax set in stone, unless you can absorb breaking changes later on. 

I find this an interesting research topic, that may prove to be a practical solution to some future area of work. Along these lines - I recently purchased a book that looks promising; Terrence Parr's book "Language Implementation Patterns - Create your own Domain Specific and General Programming Languages". Terrence Parr developed  ANTLR and that tool is used in the Boo compiler.  I will have more reading and learning to do in this area - and, perhaps at some point, the payoff will be when I can see an area where a DSL can be used to invoke parts of a framework. Ideally this would be in terms of the users, a readable Business DSL, or an API syntax that developers for an application can use that brings a higher level of abstraction and makes code more readable - and perhaps more declarative.  The Jeremy Miller video shows that is not a simple task, however, he shows that it can be used to develop some powerful solutions too, and that I find to be valuable.

Tuesday, January 25, 2011 8:05:47 PM (Eastern Standard Time, UTC-05:00)
 Saturday, October 09, 2010
The September meeting of the Atlanta Powershell User group was to be about Scripting GUI with PowerShell. Mark Schill, the leader of the group, indicated that if no one else  volunteered,  he would do it. The September meeting was cancelled due to the short time allowed for the topic, and I asked if anyone had volunteered. No one volunteered, and the topic was one I was interested in - so I volunteered for the October meeting presentation on Scripting GUI with PowerShell. This post reflects the research I did for the presentation.(Apologies to the group for posting this weeks after the presentation).

A "Graphical User Interface" or GUI, is to present a Graphical window to display data visually, or gather information from direct user input. Doing this from script means that it is not compiled into a frozen format, and that gives you  flexibility to change things quickly without recompiling a standalone program.  If you are providing your script for someone else to use - and they are more comfortable with point and click - creating a GUI is in one way to bridge that gap. If you are trying to isolate what a user can do within Powershell - building an application with the Powershell SDK as a standalone program might be a better option; but that also would be freezing the presentation format. With Powershell this is great - as you have options, and the issues are - that you have options - you have to figure out what you are trying to accomplish, and how, if you even want PowerShell script run with a GUI interface you have lots of options.

One key thing to point out is that, using version 2, Powershell console and the Powershell_ISE work differently in their execution threading model (this goes back to COM components and how they deal with threads) - that impacts doing a GUI  as there are Windows components that require a Static Threaded Aparment (STA) model, and will have issues with Multi-Threaded Apartment (MTA). Powershell console,  by default, is an MTA application - each command is its own thread. Powershell ISE by default uses an STA model. You can force Powershell console to start with the STA mode by adding a parameter -STA on the command line. Create a shortcut with the -STA parameter if you are planning on using the Console to spin up a GUI. Your other option is to run powershell from within powershell on an STA thread - Oisin Grehan wrote a post on how to do that.

When it comes to presenting a GUI from Script, there are options, which comes down to COM objects,Winforms, and WPF at the root of any GUI interface. COM objects that can accept data for presenting information, Winforms and WPF for user input. So I will review this in terms of "Data Presentation" and "User Input".

Data Presentation


PowerGadgets
One presentation option that starts with the Vista OS, is the Gadgets bar. There is a suite of tools that uses the Gadget bar called PowerGadgets -"Professional IT monitoring for under $100" which offers Gauges, Maps, and Graphs for use from powershell. However one blogger, James O'Neil, indicated that it was not well documented and has some issues. (Since my employer has not moved past XP, I am not able to comment from my experience).

Microsoft Chart Controls
One option that bloggers Richard MacDonald, and Chadwick Miller(aka Chad Miller of SQLPSX) write about is using MS Chart from Powershell. You have to download and install the Microsoft Chart controls for Microsoft .Net Framework 3.5 components, and it does require that you have .NET 3.5 SP1. Microsoft made these objects available as a download - and the Charting objects are provided as part of the .Net Framework 4, Microsoft acquired these charting controls(Visualizations) from Dundas, so these should be standard from now on. (The 3.5 download may not have the same number as the .Net 4 framework.)

In the approach of data presentation using the MSChart approach, you may have to understand the data binding. Alex Gorev, who worked for Dundas, and now for Microsoft, blogged on the Databinding with the controls. Chad Miller's post help make the transition of that information to Powershell - he created a function LibraryChart on PoshCode that encapsulates using the MSChart library.


PoshBoard
(Powershell Dashboard)
One open source option for Data Presentation  is Poshboard - that uses Silverlight and PowerShell and the Visifire components. Poshboard has posted some great previews of what is being worked toward. From France, Antoine Habert is the developer - who says he is just a scripter. He has posted some videos on the versions he has released for Poshboard. Version 3.0 beta version multitouch video, and the video demo of the stable release of version 2.5 - but at this point in October of 2010 - you cannot build this - with Visual Studio 2008 you must install the 3.0 Silverlight extensions (at least) and there is work being done on the 4.0 extensions (no audio on either video for 2.5 or 3.0)- but you get the idea of what is going on!). I tried to follow instructions on this - with a Visual Studio 2008 SP1 on XP and could not get it to work locally. Antoine Habert's Posbhoard work attracted the attention of PowerShell architect Jeffrey Snover (Poshboard was noted in his post on ConvertTo-Hashtable). With RIA Services and Silverlight on the desktop, it will be interesting to see how this progresses. This has potential that may not be easy to appreciate at this point - but has a huge potential -the churn effect of various pieces will hopefully be worked out). I would recommend following up on this project as I think it could have great value if it presents a stable installation set of instructions that works(for XP,Vista,Win7 and Server editions).

Data Interaction

Winforms and WPF are the two pieces of the .Net framework that make creation of a GUI possible from PowerShell. Winforms was the basis of the Graphical User Interface within Windows for years. The .Net framework encapsulated the Winform API in the System.Winforms.Form namespace. WPF came along with .Net 3.0 and the System.Windows.Window namespace (actually a few more than just that). These two namespaces provide the core functionality to interact with the user to capture data input from a script - if that is how you want your script interaction to operate. This does provide the flexibility of the script - and changing it as needed - pretty much on the fly - instead of re-compiling into a fixed format. The key to using these interactions - is to create an object that you add properties to within the script so that the data is available from the pipeline after the GUI interaction. The Powershell ISE exposes its script object model to the users to extend - and the Powershell ISE is a WPF application written with the Powershell SDK. So there is a great deal more control if you want to get to that level of creating a GUI for powershell. For the purpose of the presentation - and it's audience - I have tried to limit the topic to "Scripting a GUI" - as not everyone will do work in Visual Studio - Powershell scripting can be done independent of Visual Studio - and so there are areas that Developers may be familiar with, in terms of API that non-developers might find as a learning curve to work with.

Winforms

Winforms from Powershell depends on the namespace of System.Windows.Forms to gain access to the Win32 API pieces through the .Net framework. It is the API layer that gave us the windows that started years ago - built into the Windows OS. The details of the .Net usage and translating it to PowerShell is where a bit of the work lies (and that holds true for WPF too).

Bruce Payette's Powershell in Action (1st edition - Powershell 1) gives scripts that use the  WinForms abilities to put a screen before you as a user. His scripts show that it can be done, and that the details are not small to put up a GUI for data interaction. Lots of fine tuning is required in putting together a decent GUI when it starts to become complex. There is a basic set of controls provided with the 1st Edition of "Powershell in Action" - and you may find that you don't need much more than what he worked to create for his readers. If you keep things simple this is a workable solution.

Winforms from PrimalForms

Sapien Technologies created their PrimalTools.com for their tools. They have produced some Free tools and one of those is Primal Forms community edition (Free) and a professional version (currently about $150) of Primal Forms. The Free edition allows for drag and drop creation of a screen layout - and to have it take care of the fine details of the layout for free is great - but you have to figure out how to hook your scripts into the script output yourself. The Primal Forms professional edition states that you can put your scripts into events - so you don't have to figure it out on your own - and that alone could make this pay for itself. (If you are doing lots of GUI's in a winforms style, this could be a very good tool to invest in).

WPF

WPF is from the System.Windows.Window Namespace - and is possible from .Net 3.0 and afterward. The direction for the UI space from Microsoft seems to be heading toward a WPF type interface now  - Visual Studio 2010 and the Powershell ISE are good examples. Microsoft has worked on the performance of WPF as it brought out VS 2010.

WPK  
As the powershell team was working toward releasing version 2, one of the testers, James Brundage, was working on a way to use WPF from powershell - this was released as "WPK". My earlier post on learning from Powershell extensions ties right back to this idea - the Windows PowerShellpack includes the WPK PowerShell extension that gives you the basics to build a WPF screen. James Brundage, who has since left Microsoft, produced this code. It is workable however the load time is slow.


Powerboots
I recall reading Jeffrey Snover's blog post about this module, just after Jan of 2009, and was initially fascinated that someone was trying to do GUI's with WPF in powershell. I read about the basis being on the ruby "Boots". I tried an early download but it did not work for me. While I was working on the presentation, I mentioned this to Mark Schill, and he told me to Contact Joel Bennet- (who developed Powerboots), and he would help me - I did that via his website HuddledMasses.org - and I did get Powerboots to work.

If you do not see a full release of Powershell dated AFTER October 2010, you should download the latest software uploaded to the CodePlex site. You unzip that under your Powershell Modules folder (under your documenents/WindowsPowershell) and then rename the mangled name to be just PowerBoots. Then go into the bin folder and rename the PoshWpf.dll - to OLDPoshWPF.Dll   - then rename one of the other DLL's for PoshWPF to what you have on your system.

Joel 'JayKul' Bennet is a Powershell MVP, and certainly has earned it. He is working on Powerboots and improving its performance. He actively participates in the IRC Channel #Powershell. His working machine is a 64bit machine and working with .Net 4 - and that was part of the issue I had - working on an XP machine 32bit and only .Net 3.5 on my demonstration machine. A few instructions after contacting him, and I was generating windows with Powerboots.

There is a Samples.ps1 in the Powerboots/Samples directory - and that will have enough basic examples to show you what you can do with Powerboots. 

Joel Bennet had made a post of some code  I had an issue with - that he corrected and reposted during an IRC chat with him.  You can create XAML as an external file and use that in Powerboots if you want to - You do not have to create your XAML outside to use powerboots. This example was one I wanted to see how you could create your XAML in a tool designed for that, and then use that from your script. (Joel's original post of the script code). If you go to his Original post you should save the XAML to your local environment - and I saved mine in my "C:\Data\" folder and then point to that in the script.
You  see a very key piece in the script  - the use of the new-object followed by Add-Member using the pipeline.
That adds properties by name to the base object - very much the way that you can use Javascript prototypes - you can add Properties and Methods to Powershell objects. (You have to do 'Import-Module powerboots' to run the script below).

####################################################################################################################
## Create the window and hook the click. Make sure to use full paths
function Calculate-TripCost {
$result = new-object psobject
$result | Add-Member -type NoteProperty -name Cost -value 0
New-BootsWindow {} -FileTemplate C:\Data\Boots_MainWindow.xaml -On_Loaded {
#If you get an old version of Boots you wont have this
Export-NamedElement
$Calculate.Add_Click({
$Total.Text = '${0:n2}' -f (($Miles.Text -as [Double]) / ($Mpg.Text -as [Double]) * ($Cost.Text -as [Double]))
$result.Cost = $Total.Text
$BootsWindow.Close()
})
}
$result
}
Calculate-TripCost


The $result field is returned to the pipeline so it can be used after the function has completed.
You can create multiple properties to hold on to the UI elements. This would be the same tactic done with Winforms - so that you can use the data you capture.

Powerboots, using WPF, can do Transparent Windows - which allows you to create a control or test message on your desktop that has information - which seemed to be like PowerGadgets without writing to the API for Gadgets. Powerboots is a very active Codeplex project -and is preparing for a new release that will be far more performant that WPK and with a clean syntax. Powerboots will probably become the de-facto method of producing WPF GUI's from Powershell, as it has coverage for Graphics, DataInteraction, and has the performance. There is work is being done to make it work with .Net 4. I would keep an eye on this extension as it has great value potential long term.


That gives you a high level rundown of some GUI approaches for Powershell - and I hope that is helpful.

I have tried to package up what I presented in the zip file - you need to unzip it using folder names it expects to have a C:\PS1 and C:\Data folder on the machine for the script to run. You need to go to the PS1 directory using a Console window started with the -STA parameter and then use .\Start-Demo DemoIntroToGUIScript.txt - you have to have done the downloads for WPK, Powerboots, and MSGraph mentioned in this post for parts to work.


 


PowerShell_GUI_Demo.zip (38 KB)
Saturday, October 09, 2010 5:33:18 AM (Eastern Standard Time, UTC-05:00)
 Sunday, June 28, 2009

Codestock 2009 wrapped up last night.The event was oversold by 1 - 376 attendees. I enjoyed the selection of talks that were available, and the sessions I attended were good. Of course I had a favorite.

My Favorite session was delivered Rik Robinson of Wintellect. His talk was on PRISM, from the Microsoft Patterns and Practice group (PNP), this is a Guidance that can be used in WPF and Silverlight - and incorporates the Unity IOC framework (but that can be swapped out if you prefer). He kept it simple, he introduced one thing built on another, and he got the main concepts of how PRISM can be used to develop applications that decouple View and ViewModel in a very clean fasion. The session was very interactive and it must have been a bit of pressure to have the Wintellect CEO sitting in the session.

Through another acquaintance I got to have dinner with Rik that night(day of his presentation), and hooked up with him for yet another dinner after the last Codestock session before driving back (we did not attend the giveaways).

Wintellect is local to Knoxville, and is one of the supporters of Codestock. They arranged to have to other presentations besides Rik Robinson's. John Robbins and Jeffrey Richter gave presentations via live meeting - and took questions via cell phone (which you would hear in the room as an echo - but it worked). I attended the John Robbins debugging presentation and it too was excellent (he can make technology humourous) - I picked another session instead of the Jeffrey Richter session - if they recorded it I am going to go watch it.

I feel a bit responsible for a comment from another attendee about one session I attended. The session just seemed like there were more examples that were ready - but not shown - and the session ended earlier than the time slot. I overheard someone else make that comment about it - and it seemed to fit. I had been fine with how it was -and only when I heard the comment did it occur to me that not all of the examples had been touched on. I had sat down to lunch with this speaker before his presentation. It occurred to me that I may have impacted his preparation, and even the thought that I did impact his presentation makes me feel sorry for having disturbed his preparation. I felt it was still a good presentation. I heard how much Rik Robinson prepared and saw the result - it is a lot of work - and it makes me wonder if my trying to be social - was just at the wrong time (My apologies to the speaker)

There were several topic areas of interest for me during codestock. WPF,PRISM, MEF, Debugging, WCF, ORM usage, and TDD. There were sessions that touched on, or spoke to these - and much more.

Another acquaintance suggested I attend Kevin Hazzard's session on "How I learned to love Metaprogramming" - which was a very good look into the way that the compiler creates a dynamic data type in .Net 4.0. The data type of dynamic - is static. That statement seems at first to be an oxymoron - but the element is treated as static and how it resolves at runtime is dynamic. The presentation showed how C# and Python could interact - and gave some examples of dynamically wrapping elements of XML using C# using the Dynamic elements. His XML Example reminded me of something that Powershell can do today - and Kevin said that the powershell team did not go down the Dynamic Language path - which he was not pleased with. Kevin Hazzard is a very good speaker and he gets into the topic very deeply - and explains it well. I would like to hear more about his perceptions on Powershell, and how he thinks it might have been done.

There was one connection that I did not expect to occur. At the CodeStock social event, I was sitting at a table, and a fellow walked over and looked at me and said - I think I know you. After a moment or two - I recogognized him from a twitter photo. When I went to Devlink 2008 - I was trying to use Twitter to find out where people were meeting up, and I had been on twitter for maybe a month at that time. This fellow was not able to attend the DevLink event - but was trying to follow what was going on - and he responded to help me figure out where people would be. Between this fellow and "TheCodeCampJunkie" - I was able to hook up with people at DevLink. So here was my first time meeting a person face to face - based on using twitter. We talked about .Net and his getting certified and how it was not helping him get work.

The main focus of these event is the dissemenation of knowledge of what is new and how to use the technology we deal with. The other part of this is that you are meeting and speaking with other developers, whom you may have not ever met otherwise.

Several people have posted pictures from CodeStock - Alan Barber got one picture of me at the Dinner on the night before the event.

Sunday, June 28, 2009 7:37:48 AM (Eastern Standard Time, UTC-05:00)
 Sunday, April 19, 2009

Today - I was trying to "catchup on" (and cleanup) my downloaded podcasts. I heard Show 81 with Shawn Creamer from Microsoft on Performance Monitoring and it spoke about a Technet article by Steven Choy also from Microsoft. They referred to it as a PDF but the link is the Technet article.

Shane Creamer stressed that people need to learn how to use the performance monitoring tools, and the article identifies the 25 most important counters that developers and IT staff need to be aware of.  This information is something that I will want to come back to and feel that others would find of great interest also. Shane teaches a course on Performance monitoring to pinpoint issues.

The RunAsRadio did post a video on the site that goes with the Show 81 - but did not put sound that came from the show which dramatically lessened its value.

RunAsRadio also had an interview (Show 77)with Steven Choy who speaks about performance monitoring and virtualization. Both shows were good. and I would recommend given them a listen.

Sunday, April 19, 2009 11:26:31 AM (Eastern Standard Time, UTC-05:00)
 Wednesday, November 05, 2008

I found a link tonight that led to a Codeplex project http://www.codeplex.com/cracknetproject.

From the Codeplex site

Crack.NET is a runtime debugging and scripting tool that gives you access to the internals of a WPF or Windows Forms application running on your computer. If you love Snoop and Mole for Visual Studio, you’ll love Crack.NET, too. Crack.NET allows you to “walk” the managed heap of another .NET application, and inspect all values on all objects/types.

This looks like a good tool in becoming familiar with what is going on in WPF and Winform apps.

 

 

Wednesday, November 05, 2008 10:04:02 PM (Eastern Standard Time, UTC-05:00)
 Friday, September 05, 2008

At the DevLink codecamp, in Murfreesboro TN, I met a developer before the keynote, Corey Haines. He started explaining some things about how Ruby was a language that was going to change the developer experience, and then proceeded to demonstrate a very simple app that he got up and running in minutes - a web site application.

I attended the meeting where the Open Spaces were being planned and session on how Ruby was affecting the profession (or something like that) was proposed as a subject. I was curious - twice within a few hours - this topic had appeared.

I was standing in front of the OpenSpaces board later, and discussing the subjects with people who were standing around, and when I mentioned the Ruby discussion that was going to happen, two older individuals - who seemed like Managerial types chimed in that they have seen that developers can be very productive with Ruby. OK - that is three times before lunch and the subject of Ruby has been put in front of me - this is getting to be a bit ridiculous - so - my curiosity is growing.

The Ruby Language - is not used at my employer today (that I know of). The main impression that I got was that the productivity using Ruby can be an order of magnitude more than what other languages offer. This was a set of information that will take me a while to digest and experiment with.

I have downloaded IronRuby and got some learning materials to go through. I can see that the roots of Perl are in some of this. It will take some time with all the things I have going on right now. 

The little I have read indicated that both Python and Perl were not sufficient for the developer of Ruby, and that is how the language got its start. The breadth of technical areas that the books I got shows that this is a maturing language - I am sure that there will be more to say later as I have digested a bit of what I am learning.

Here are the books I got to become familiar with Ruby

 

Friday, September 05, 2008 4:43:38 PM (Eastern Standard Time, UTC-05:00)

I saw a Hansleman tweet about his investigating the Mesh dll's and that the CoreCLR.dll was in there. Indicating that a desktop app might be able to use a reduced CLR via the Silverlight DLL. One of the first comments from that pointed to this http://www.blendables.com/labs/Desklighter/Default.aspx which looks like it has used the Silverlight CLR for a desktop app.

There was something that I saw about someone might learn Silverlight and then approach desktop apps using WPF before doing it the other way round. There may be something to that idea. I will have to investigate that more.

Hansleman indicated that this could be a way of doing some cross platform development with a much smaller foot print that the whole .Net Framework.

It makes me wonder about how the licensing reads for using Silverlight - can you use it offline?

 

 

Friday, September 05, 2008 3:41:09 PM (Eastern Standard Time, UTC-05:00)
 Monday, January 28, 2008
FxCop Code analysis tool has been getting harder to find,this has a link to find more info on it.
Monday, January 28, 2008 11:11:38 PM (Eastern Standard Time, UTC-05:00)
 Tuesday, January 15, 2008
Interview article with Andrew Troelsen mentioned a cross platform library that is C# .Net compliant. It works with Native OS (Mac/Linux/Windows) and the footprint is very small compared to Java and others.
Tuesday, January 15, 2008 9:48:58 PM (Eastern Standard Time, UTC-05:00)