Saturday, 29 September 2012

Nuget

NuGet is a Visual Studio extension to make it easy for you to find and install third-party libraries and tools. As of September-end 2012, NuGet has had 25 million downloads. Amongst the packages available on NuGet, there is Json.NET, a high performance Json framework for .NET.

Wednesday, 26 September 2012

PFX (Parallel Extensions) built on System.Threading.Tasks

What is PFX? (I heard about it on Channel 9).

PFX stands for Parallel Extensions for the .NET framework (released in .NET 4.0) and is something of increasing importance, judging from the multiple references to PFX on channel9.msdn.com. This post will be a primer to PFX - getting you up-to-speed with the basic terminology and concepts.

Who developed PFX?

Both Microsoft Research and the CLR team were involved in the development of PFX.

Two Parts to PFX and their Relationship

First is Parallel LINQ (PLINQ) and second is Task Parallel Library (TPL). PLINQ uses TPL for execution. The other technical term is CDS which stands for coordination data structures - used to synchronise and co-ordinate execution of concurrent tasks.

Example

using System.Threading.Tasks;
Parallel.ForEach(myListOfStrings, s => Console.WriteLine(s));

Data Structures for Parallel Programming

More can be found here. Ex: System.Collections.Concurrent.ConcurrrentDictionary<Key,Value>

IE9 heralds HTML5 Video Support

HTML5 defines a new element (<video>) specifying a standard way to embed video in a web page (supported in IE9, Chrome, Safari, Firefox).  Supported video formats are:
* MP4 - MPEG4 files (H264 video codec, AAC audio codec
* WebM - WebM files (VP8 video codec, Vorbis audio codec
* Ogg - Ogg files (Theora video codec, Vorbis audio codec)

Reactive Extensions (Rx)

About time WinJoe covered Reactive Extensions, Rx, an interesting library for handling streams of data. It is starting to be used as a tool for CEP (Complex Event Processing) applications.

IE7 is already in the History Books

Many modern websites (e.g. force.com) have no support for IE7. IE8 is built from the ground up. It passes the Acid2 browser test (documented on the Web Standards Project website), IE7 fails. This shows IE7 has poor web standards compliance! Acid2 tests support for so-called "data URLs" (RFC 2397).

IE8 also introduces some web security-oriented features. Some of these are MS-specific (e.g. restrictions on ActiveX controls) whilst others are more wide-ranging (e.g. relating to cross-site scripting (XSS)).

To understand web security, a good resource is OWASP (Open Web Application Security Project) whose mission is to "make software security visible".

Sunday, 23 September 2012

The Importance of Managed Debugging Agents (MDAs)

MDAs work with CLR to provide information on runtime state. One of the most famous MDAs is loaderLock MDA.

The idea of MDAs is to isolate hard-to-find app-bugs when transitioned from managed to unmanaged code.

Thursday, 13 September 2012

MSVS 2010 Autoformat Code

Cntrl-E Cntrl-D.
(Eclipse: Cntrl-shift-F)

WPF Multibindings

Bind multiple items and return a single value.

Excellent functionality in all kinds of control panel scenarios.

The WPF DataGrid - Explained

It might seem mysterious how one can populate a WPF DataGrid from System.Windows.Controls, the "Fourth" Incarnation of the DataGrid.

Answer: Create your own ObservableCollection

All lies in setting the ItemsSource property to an ObservableCollection of custom-built ViewModel objects. As we know from MVVM design, the ViewModel is just like a "screen" on top of the Model that keeps the Model up to date and is also responsible for notifications when properties change, to the relevant observers.

From ObservableCollection to NotifiableCollection

ObservableCollection is good for dealing with "macro" changes to the Collection (as when an Item gets added or deleted) but is not good at detecting and propagating changes when properties on individual items change. For that, a custom-built NotifiableCollection is appropriate (see this discussion on forums.silverlight.net (general principle applies to WPF also)) and also this blog post from a software consulting firm specialising in "nearshoring").

Declaring the NotifiableCollection has to be done in "Generic" Style

public class NotifiableCollection<T>: ObservableCollection<T> where T: class, INotifyPropertyChanged {... }

Note that you also need to declare an EventHandler within the Collection definition, which can be simply done: public event EventHandler<MyEventArgsClass> InterestingPropertiesChanged, or some such similar declaration. Conceptually, this is like defining a multicast delegate to hold the function pointers representing methods to be invoked when an "interesting" property is changed.

Conclusions

The main conclusion is this.

It's nice to know what you can do in WPF using System.Windows.Controls. But a knowledge of controls alone is no use without working knowledge of the relevant object model and component model namespaces.

Thes are System.ComponentModel (INotifyPropertyChanged) and System.Collections.ObjectModel (ObservableCollection). Understand the ComponentModel and Collections Object Model in detail.

Tuesday, 11 September 2012

Respect to System.Windows.Input

For it brings us the RoutedCommand.  RoutedCommand is a central pillar to Commanding in WPF and implements the ICommand interface (also part of System.Windows.Input) with which every .NET programmer should be really familiar with. ICommand? Oh yeah, that old thing. That means the RoutedCommand has to implement Execute and CanExecute, is all. And not just RoutedCommands, either. Also RoutedUICommands, which is, like, a special case of a RoutedCommand. I won't explain the differences between the various RoutedCommands. Let experience be your teacher.

Recap: Name three classes in System.Windows.Input related to Commanding. Hint: See Above.

But one thing we must mention.

System.Windows.Input ain't just about Commanding. 

Oh no, there's a whole PLETHORA of crazy stuff in there. Everything to do with the WPF input system, including keyboard, mouse and stylus input processing types. One such crazy class would be e.g. StylusButton, that represents a button on a stylus. Much cooler than going pound-include iostream; and all that malarkey in C++. Forget C++. This is the Age of C#.