ObjectSharp Blogs

You are currently viewing

Justin Lee's Technology Blog


Languages, Languages, Languages!


VSLab - F# Visualization

Visual Studio Lab (VSLab) exploits the power of F# and its interactive top level to provide an interactive environment similar to MatLab and Mathematica, in which you can easily create Add-ins and interact dynamically with them inside Visual Studio. Moreover, since F# is a compiled language, the final code can be compiled as a standalone application.
Goal of the project is to provide the basic infrastructure to turn Visual Studio in VSLab, and a number of addins (called viewlets) used to show data and support development of scientific based applications.

Take a look. :) I assure you that you'll be impressed.

Another Reason to use Flash Instead of Silverlight

Flash content is finally searchable by two of the biggest online search engines on the internet, Google and Yahoo.

One of the biggest disadvantage of using Flash content for your dynamic content is simply because it is not searchable, and now with Adobe's new optimized Adobe Flash Player helping both Google and Yahoo to search and index Flash content, this means that there is no excuse left NOT TO USE FLASH on your web sites.

Note that Microsoft Live Search was not included in this partnership.

Now, for those enthusiastic about writing Silverlight content on the web, might I ask, what is Microsoft going to do about this? Both in its Live Search, making it competitive with Google and Yahoo to search Flash content, and also making Silverlight content searchable too. This is the biggest advantage Adobe Flash has over Silverlight now, and if Microsoft doesn't do anything about it, the web will not be convinced about Silverlight, regardless of the amount of bribing promoting they can and will do.

Adobe, we love you and thank you.

To those Silverlight enthusiasts, please get your facts right about Adobe Flash before even bashing Adobe Flash technology. You know who you are.

Blaming the User

Is it better to have a user implicitly learning how an application work easily by discovery, rather than explicitly learning how an application works through training and books?

If something goes wrong with an application, is it really a "problem between the keyboard and the chair"? Or is it because the "User Experience" isn't sufficient or consistent to assist with implicit learning?

Sometimes people in the "Computer Industry" need to think more about the user and how to ease their pain, instead of blaming them and create more pain for them.

I'm always amazed when a user tells me "It just works! Amazing!" instead of "How do you do this?". That's "User Experience" for you.

Think about it.

This is my rant today.

Links on F# Quotation

These are a few links I want to read later on F# Quotations. Quotations are similar to expression trees in C#, but more powerful.

F# - Simple quotations transformation

Practical F# Parsing: The Abstract Syntax Tree

F# Quotations Samples on CodePlex

F# quotations visualizer - reloaded!

Some Q&A on F# Quotations and LINQ

MVP Insider - Q & A with Justin Lee

Well, it seems this month I'm up for being interviewed. Here's the link to my interview.

WPF for Developers and Lead Designers Course

Rob Burke is teaching a WPF training course through Toronto-based consultancy ObjectSharp. The course is called “Windows Presentation Foundation for Developers and Lead Designers,” and, as the title suggests, it offers a hands-on experience designed to give developers and lead designers the knowledge, background, tips and references they’ll need to build smart client applications using the Windows Presentation Foundation.

After enjoying the process of training a team of developers and designers to use WPF, this course is the result of turning that material into a course that we could offer here.

The inaugural course offering is currently scheduled for August 13th-15th. If you’re interested in taking part, please find more information about the course on ObjectSharp’s site. Also, if August 13th is too long for you to wait, or you’re interested in an on-site course, please contact Julie James, ObjectSharp’s Training Manager.

More on Rob Burke.

Pex 0.5 Released

What is Pex?

Pex generates test inputs that cover all, or at least many of the corner cases in your .NET code. These test inputs are plugged into parameterized unit test that you write. The result is a small unit test suite, where each unit test calls the parameterized unit test with particular test inputs. There is a great picture on the main Pex page that illustrates this process.

Pex supports other unit test frameworks since the unit tests that Pex generates can be executed by other unit test frameworks without Pex. Pex comes with support for MSTest, the unit test framework of Visual Studio, out of the box. For support for other unit test frameworks, please look at the Pex Extensions project.

Parameterized unit tests have been around for quite some time already, under several names -- row tests, data-driven tests, theories, etc.

What is really unique about Pex is that it analyzes your .NET code, instruction by instruction, to understand what your code is doing. Then, in a fully automatic way, Pex computes relevant test inputs that trigger the corner cases of the code. When you write assertions, Pex will try to come up with test inputs that cause an assertion to fail.

Feedback

To ask questions, get help, or just give feedback, please take a look at our mailing lists.

Links

Homepage: http://research.microsoft.com/pex

Download: http://research.microsoft.com/pex/downloads.aspx

Nikolai Tillmann's Blog: http://blogs.msdn.com/nikolait

Peli de Halleux's Blog: http://blog.dotnetwiki.org/

Release of Microsoft Source Analysis for C#

Source Analysis, also known as StyleCop, analyzes C# source code to enforce a set of best practice style and consistency rules.

Source Analysis for C# can be downloaded here: https://code.msdn.microsoft.com/Release/ProjectReleases.aspx?ProjectName=sourceanalysis.

Source Analysis Blog: http://blogs.msdn.com/sourceanalysis

QuickSort in Functional C#

Here's a very simple QuickSort algorithm from Wikipedia written in a very Functional way of C#. Notice that it looks very close to the pseudo-code algorithm shown in Wikipedia. The pivot used is just sequence.First(). You can replace the pivot by some random position if you wish.

   1:          public static IEnumerable<T> QuickSort<T>(this IEnumerable<T> sequence) where T : IComparable<T>
   2:          {
   3:              return !sequence.Any()
   4:                         ? sequence
   5:                         : ((from x in sequence.Skip(1)
   6:                             where x.CompareTo(sequence.First()) < 0
   7:                             select x)
   8:                               .QuickSort()
   9:                           ).Concat(new[] { sequence.First() }).Concat((from x in sequence.Skip(1)
  10:                                                                        where x.CompareTo(sequence.First()) >= 0
  11:                                                                        select x).QuickSort());
  12:          }

I tried making this more fun by using the Fix Point Generator which I mentioned previously, and converted that code into a Func<IEnumerable<T>> instead. Here's the code.

   1:          public static Func<T, T> Fix<T>(Func<Func<T, T>, Func<T, T>> F)
   2:          {
   3:              return x => F(Fix(F))(x);
   4:          }
   5:   
   6:          static void Main()
   7:          {
   8:              var quicksort = Fix<IEnumerable<int>>(
   9:                  qsort =>
  10:                  sequence =>
  11:                  !sequence.Any()
  12:                      ? sequence
  13:                      : qsort(from x in sequence.Skip(1)
  14:                              where x.CompareTo(sequence.First()) < 0
  15:                              select x)
  16:                            .Concat(new[] { sequence.First() })
  17:                            .Concat(qsort(from x in sequence.Skip(1)
  18:                                          where x.CompareTo(sequence.First()) >= 0
  19:                                          select x)));
  20:          }

This is a perfect example of how you can use the Fix Point Generator to create your recursive functions on the fly. If you want to make it reusable with an extension method, you can easily convert it to the extension method, or a normal method. Personally I feel that using the Fix Point Generator is more intuitive and slightly more readable as oppose to the extension method way of doing things.

One point to note is that the "Concat" extension only accepts an IEnumerable<T> and not a single item. You can solve this by the above, "new[] { sequence.First() }" which is a cleaner way if you don't want to write your own extension method (which you could too).

Crazy stuff eh?

Presentation: Practical Functional Programming in C#

Here are my slides I've done at DevTeach Toronto 2008

Download it here.

More Posts Next page »