Monday, December 6, 2010

Balsamiq Mockups

This is something that has been around for a while now.  I first tried it years ago but I had not any real usage for it back then.  Last week, I needed something to capture a UI change I was planning to do in my project.  My first though was just draw on a piece of paper, but I have to e-mail this to someone off site.

What should I do? Scan my drawing, Paint or SketchFlow? No, Balsamiq Mockups!

On the web site there is an introduction video and a web demo you can use to get a feeling of the tool.  The best part is that I was able to create a simple UI including the changes I was planning do to in less than 5 minutes and downloaded the PNG directly from my web browser!

It works really well to create low-fi prototype of fat clients, web apps and even iPhone UI.  Additional controls can be downloaded provided by the community.  Finally Balsamiq Mockups can be embedded in other tools like Confluence, JIRA, FogBugz and XWiki.

If I ever need to do a lot of UI prototyping I think a 79$ for the full version will be really well spend.

Thursday, November 25, 2010

Pex4Fun

Check out this really cool web site. Not only you can write code in your browser you also have IntelliSense. The way it works is you are given a puzzle or a duel to solve (think code breaker C# edition). The goal of the game is to write the same algorithm than the hidden solution. You get hints by running Pex against both the hidden puzzle and your solution.

Pex is a tool that will try to call a function with any kind of input parameters required to use all the code path of the function. It will highlight thing like passing null might cause a NullReferenceException down the line and you should guard against it. So by trying all those combinations against your code and the hidden puzzle will give hints on the difference of implementation. You can then update your code and try again each time getting closer and closer to the solution.

You can even create an account and keep track of all the challenges you solved. A section of the site is structured as a course where you learn about C# and cool features like Code Contracts.

Code Contracts helps us create a more declarative way of expressing pre and post conditions to our code. And because of the declarative way they works, tools can then to provides us with static compile time validation, run time guard code and automated API documentation of the contracts.

Pex4Fun is really a great way to play around those 2 great tools without having to setup libraries on our machine. I can even show some basic C# stuff to my friends, on the web and even from my smart phone (but then it’s not that fun I must admit!)

Tuesday, November 9, 2010

Introduction to LinqPad

It’s really sad that in the late 2010 most people still don’t know about this incredible little tool.  For me it is a bit like what Reflector used to be in the early days of .Net, a great and FREE productivity tool outside of the Visual Studio IDE and Microsoft tooling.


LinqPad was created by Joseph Albahari as a companion tool for his book C# 3.0 in a Nutshell.  You don’t have to buy the book to use the tool (actually I haven’t bought the book either! me bad).
It’s really difficult to do justice to LinqPad in a small blog and I don’t want to write a too long post so I’ll try to expose the most useful features to you today and eventually blog about specific ones in detail in the future.

Code Snippet execution

This is the reason I use LinqPad almost every day.  If I want to test a snippet of code I don’t create a dummy VS project, I simply try it in LinqPad.  You can even write a full program if you want and save it as a code snippet.  I use this to create most of my utility tools like when I need to read and display an xml file or generate one I just use LinqToXml.


LinqPad1

Learning Tool for Linq and other .Net features

Went I first found out about LinqPad it was when .Net 3.5 came out and understanding Linq queries was still hard for me.  The tool has a lot of good Linq code sample built in so I could learn and play with the queries.  What makes this interesting is the Dump extension method of the Object type which is really powerful to display the state of any simple or complex data structure.

LinqPad2

Integrated LinqToSql

Another useful thing to do is connecting to a database and have LinqPad setup a LinqToSql wrapper over the schema so you can query it with code rather than SQL.  I cannot say I’ve used this feature a lot but sometime it can be nice if you want to do some processing of data coming from a database.  A Linq to Entity and OData options are also available.  In the future I guess I’ll be using LinqPad to query source like NetFlix and the other OData feeds too.

LinqPad3

External Library

This is something new for me (and I guess to a lot of people given I haven’t seen much info about it on the net), you can load any dlls in LinqPad to use in your queries.  This is an excellent way to create libraries of useful functions and extension methods.  I’ll be using this feature to query assemblies using Mono.Cecil with some extra functions of my own.  I’ll share with you the result of my experiments in a future series of posts.


Go download LinqPad!  You should definitely give this great tool a try.

Saturday, October 30, 2010

Fun with Mono.Cecil

I’ve always loved playing around with tools like Reflector and NDepend to take a look at the internals of my code base but with an external perspective than inside Visual Studio. 

Reflector was really useful to me to walk dependencies and hierarchies before I started using Resharper.  NDepend is an amazing piece of software that gives me a lot of metrics and other information.  Unfortunately maybe a bit too much, it’s hard to make head and tail a first glance.  I’ve never had the chance to play with the full version and the trial is very well done in the way you can use most of the software but it’s nagging you just one step before you could nail something really useful.

Now in Visual Studio 2010 we have the Dependency Graph which is really neat but difficult to use because of missing key features like a way to control or filter the noise of been force to graph the whole solution.  You always need to start pruning the graph from scratch and zooming on a single namespace and dependency is hard.  Never the less, with a bit of patience I can find a lot of information like dependency circles.  But again, when I find one I’m stuck with only visual information, no way to just extract a list of namespaces, types or methods to help me tackle the culprits.

So, that is where I am now.  I’d like to have something as powerful as Reflector to walk the links, complete as NDepend and Dependency Graph to get all the information I need to learn about, break bad dependencies but also prevent new ones from appearing in my code base.  Wouldn’t be nice to be able to query the code base for metrics, dependencies and general patterns in my code? Tests to help me keep my code clean?

Of course I know that NDepend got this CQL feature.  It’s really amazing but with the trial version of the software I can’t go far.  And to be honest the editor is a bit clumsy and the language a bit limiting.  No, what I need is a better experience, something really interactive to play with my queries until I get them right, something like the experience I get with LinqPad.  Then I can put the result of my efforts into a unit test to be sure I’ll won’t repeat the same mistakes again.

.Net reflection API is all good in theory but to use that I’ll need to be really cleaver because reflection works only by loading a dll in memory before querying it.  And due to the way the CLR works, a dll can’t be unloaded from the AppDomain meaning that you need to close the app every times you want reload a new version.  Too bad for that.  There are ways to go around that limitation but I want to keep it my solution simple.  So an alternative to reflection is Mono.Cecil.  I’ve been hearing a lot of good about this library in the past and I know that a lot of good software use it (like NDepend!) but I never took a look at it myself.

I think it’s time for me to give it a try.  I’ll blog about my experience with it trying to create a thin API on top of it to add metrics and a way to list all the bad dependencies in my code base.