TWC9: January 6, 2012 - C9 Video Queue, Silverlight 5, Metro and WP7

This week on Channel 9, Dan is joined by new-member-of-the-team Rick Barraza to discuss the week's top developers news, including:
Picks of the Week!
my recommendations:
Localized versions of Silverlight 5 Tools !!!!
http://www.microsoft.com/download/en/details.aspx?id=28358
PowerShell 3 and DLR
http://huddledmasses.org/powershell-3-finally-on-the-dlr/
CodeMash 2.0.1.2
http://codemash.org/ http://codemash.org/Sessions/Technology/.NET">.NET and http://codemash.org/Sessions/Technology/Windows%208">Windows 8 content, Jon Skeet is here
EF 4.3 Beta 1 (and announcing EF 5.0)
http://blogs.msdn.com/b/adonet/archive/2012/01/12/ef-4-3-beta-1-released.aspx
Code signing for the independent developer (a bit old though)
http://timheuer.com/blog/archive/2011/12/12/code-signing-for-independent-developer.aspx
Dorian Corompt's posts about functional programming
http://blogs.msdn.com/b/doriancorompt/
On the subject of INotifyPropertyChanged, the Anders Hejlsberg Way.
The only issue I have with it is that it as to replicated across classes.
Now as I see it, if you slightly modify the code you can make it an extension method.
Different interface, so you raise the event on the correct object. (As I don't no a way to externally trigger them.).
Public Interface INotifyPropertyChanged_Extd Inherits INotifyPropertyChanged Sub RaisePropertyChangedEvent(ByVal source As Object, e As PropertyChangedEventArgs) End Interface Public Interface INotifyPropertyChanging_Extd Inherits INotifyPropertyChanged_Extd Sub RaisePropertyChangingEvent(ByVal source As Object, e As PropertyChangingEventArgs) End Interface
Then you have the following extension method(s).
Imports System.Runtime.CompilerServices Imports System.ComponentModel Imports System.Collections.Generic Public Module Exts <Extension> Public Sub SetProperty(Of T, U As INotifyPropertyChanging_Extd)(ByVal obj As U, [property] As String, toValue As T, ByRef usingField As T, Optional ignored As Object = Nothing) If obj Is Nothing Then Exit Sub If Not EqualityComparer(Of T).Default.Equals(usingField, toValue) Then Dim old = usingField obj.RaisePropertyChangingEvent(obj, New PropertyChangingEventArgs([property])) usingField = toValue obj.RaisePropertyChangedEvent(obj, New PropertyChangedEventArgs([property])) End If End Sub <Extension> Public Sub SetProperty(Of T, U As INotifyPropertyChanged_Extd)(ByVal obj As U, [property] As String, toValue As T, ByRef usingField As T) If obj Is Nothing Then Exit Sub If Not EqualityComparer(Of T).Default.Equals(usingField, toValue) Then usingField = toValue obj.RaisePropertyChangedEvent(obj, New PropertyChangedEventArgs([property])) End If End Sub End Module
Example Class using this extension method.
Public Class Example Implements INotifyPropertyChanged_Extd Private _Value As Integer Property Value As Integer Get Return _Value End Get Set(value As Integer) Me.SetProperty("Value", value, _Value) End Set End Property Public Event PropertyChanged(sender As Object, e As PropertyChangedEventArgs) Implements INotifyPropertyChanged.PropertyChanged Public Sub RaisePropertyChangedEvent(source As Object, e As PropertyChangedEventArgs) Implements INotifyPropertyChanged_Extd.RaisePropertyChangedEvent RaiseEvent PropertyChanged(source, e) End Sub End Class
And the _PropertyChanged event being handled.
Class MainWindow Private WithEvents MyExample As New Example Private Sub MyExample_PropertyChanged(sender As Object, e As ComponentModel.PropertyChangedEventArgs) Handles MyExample.PropertyChanged Debug.WriteLine(e.PropertyName) End Sub End Class
INotifyPropertyChanged, the Anders Hejlsberg Way:
Good feedback and an interesting discussion.
In terms of visual density, this was partly due to the fact that Anders codes using K&R style bracing instead of Allman, as well as the extra code he uses to properly avoid the race condition that exists in the MSDN example. I updated the blog post to use Allman style for both.
The other thing I did want to point out was that there is at least one other advantage besides just reductions in raw lines of boiler plate code in property setter, which is that it sets up a Pit of Success for properly implementing INotifyPropertyChanged in subclasses.
I work on a very large WPF/C# enterprise project at the moment and there are literally *thousands* of incorrectly implemented properties in the application that need to be fixed to properly check for inequality before setting the field and raising the event.
I appreciate the discussion even if you don't agree with the post. (:
Welcome to the C9 team, Rick and Brian!
Cheers,
C
I started watching this podcast on my bus ride into work today. Rick, you used a term I've not heard before, called "New Developers". I think you said it is a term that was introduced at the Build conference. I wasn't able to make the Build conference, so would you please define what that term means.
Hi Rod, Sorry for the delay. I was heads down in code and just got out. I said "New Developer" but the phrase that was introduced was actually "modern developer". I think that one is more accurate, but still very amorphous right now. At the core, would be the "traditional" seasoned developer, tackling the big, hairy enterprise level projects and master weilder of all things COM or .NET. That's really the foundation. But we're entering a time where building on top of that are a vast army of web developers, Javascript masters, interaction developers, designers who code, scripters, etc. In Windows 8, we're seeing an introductory level playing field between C++, Javascript and C#. Canvas and HTML5 are blowing up, and DirectX 11.1 becoming more accessible through the OS is going to also create a lot of great opportunities for everyone up and down the stack. From Designers who code all the way down to enterprise dev super stars. From Phone to Hardware to Cloud, from browser based scripts all the way down to running native on the metal and GPU. I think of "modern developer" as being representitive of this entire spectrum, and that's how I was using it. A sign of the massive opportunities coming into the Microsoft ecosystem. Hope that helps. - rk
@rbarraza: Rick, it's my turn to apologize for not responding sooner. WOW, almost a month after you replied to me. I'm sorry!
Thank you for your description as to what you mean by a "new developer". It's interesting, then, as it now seems like Microsoft is going to make it possible for the hobbiest developer to get back into the game, so to speak. I know that you meant more than that, but it seems as though the new developer would be someone who isn't necessarily a heavy duty enterprise developer (although they're included), but could also be the person who writes a few scripts on the side, occasionally dabbles in HTML and JavaScript, that Windows 8 will open it up for people like that again. Something that was lost with each new version of VS.
Welcome Dan. And a nice video though, several interesting things.