A fun brain exercise: PexForFun

The Pex team has created a site that provides a great tool to exercise your brain, learn a bit of code, and see a bit about Pex.

To use it, just go to the PexForFun site. There are puzzles, learning exercises, and duels.  Register and you can create your own challenges. (I’ll be doing this over the next month or so.)

The puzzle structure is a great demonstration of Pex. When you start a new puzzle, you have a empty implementation. You can click Ask Pex to get some test results on the hidden successful implementation. Pex then executes those tests on your code. You’ll see some failures, and you can fix your code to make the tests pass.

Then, you can click “Ask Pex” again, and see if a more extensive test suite still passes. Iterating this way gets you to write more code and your implementation gets closer to the expected solution. If you are not familiar with Test Driven Development, I highly recommend it. You’ll get a real feel for creating code to an executable specification instead of a written spec.

All in all, there are several reasons I like playing with PexForFun:

  1. It’s practice for Test Driven Development. you start with an empty implementation, and see a few failing tests. Keep making a few pass and you’ll get more tests. After a few iterations you’ll have everything working.
  2. It will give you some practice writing tests. Pex generates tests by analyzing your code. It determines a number of interesting inputs to code by analyzing its structure. You can read an overview here: http://www.pexforfun.com/Documentation.aspx#HowDoesPexWork By seeing the inputs it chooses, you’ll get some ideas how to write your own tests. By thinking about inputs it chooses to ignore, you can get better at writing useful tests instead of more tests.
  3. It exercises your brain. The puzzles range from introductory to rather complicated.
  4. You can pick different languages for your puzzles: C#, VB and F#.

Learn some new techniques, exercise your brain, and most of all: Have fun!

Created: 2/15/2011 8:37:01 PM

Current Projects

I create content for .NET Core. My work appears in the .NET Core documentation site. I'm primarily responsible for the section that will help you learn C#.

All of these projects are Open Source (using the Creative Commons license for content, and the MIT license for code). If you would like to contribute, visit our GitHub Repository. Or, if you have questions, comments, or ideas for improvement, please create an issue for us.

I'm also the president of Humanitarian Toolbox. We build Open Source software that supports Humanitarian Disaster Relief efforts. We'd appreciate any help you can give to our projects. Look at our GitHub home page to see a list of our current projects. See what interests you, and dive in.

Or, if you have a group of volunteers, talk to us about hosting a codeathon event.